我目前正在试图端口代码到Visual Studio 2012,使得使用模板的别名,就像这样:模板别名2012
template< typename T > using SmartPtr = std::shared_ptr<T>;
然而,的Visual Studio 2012不支持模板别名。
是否有可能将上面的声明替换为不会破坏使用它的代码的等价物?
问候
我目前正在试图端口代码到Visual Studio 2012,使得使用模板的别名,就像这样:模板别名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
但是这仍然意味着我必须用SmartPtr
@ user5024425是的,但是如果你不能使用你必须做的模板别名。 – Simple
嗯,如果我尝试继承,该怎么办:template
是否使用模板走样在专业化?继承可能是一种解决方法。 – Jarod42