gpt4 book ai didi

c++ - Visual Studio 2012 中的模板别名

转载 作者:搜寻专家 更新时间:2023-10-31 02:17:21 24 4
gpt4 key购买 nike

我目前正在尝试将代码移植到使用模板别名的 Visual Studio 2012,如下所示:

template< typename T > using SmartPtr = std::shared_ptr< T >;

但是,Visual Studio 2012 不支持模板别名。

是否可以用不会破坏使用它的代码的等价物替换上面的声明?

问候

最佳答案

template< typename T >
struct SmartPtr
{
typedef std::shared_ptr< T > type;
};

用作:

SmartPtr<int>::type

关于c++ - Visual Studio 2012 中的模板别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35864403/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com