user5024425
user5024425

Reputation: 427

Template alias in Visual Studio 2012

I'm currently trying to port code to Visual Studio 2012 that makes use of template aliases, like this:

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

However, Visual Studio 2012 does not support template aliases.

Is it possible to replace the above declaration with something equivalent that will not break the code that uses it?

Regards

Upvotes: 2

Views: 566

Answers (2)

Zak Goichman
Zak Goichman

Reputation: 71

You could try using macros:

#define SmartPtr std::shared_ptr;

works the same as template aliasing on VS2015

Upvotes: 0

Humam Helfawi
Humam Helfawi

Reputation: 20304

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

Use it as:

SmartPtr<int>::type

Upvotes: 2

Related Questions