如何在Visual Studio 2013中为函数类型创建类型别名?

voi*_*ter 0 c++ c++11 visual-studio-2013

使用VS2013,我可以为函数类型创建一个typedef,如下所示:

typedef void ResponseCallback(std::string const&);
Run Code Online (Sandbox Code Playgroud)

是否可以使用类型别名(我可以访问C++ 11功能)来做同样的事情?我一直试图从使用中迁移,typedef因为using看起来更加一致.我尝试了类似下面的东西,但它不起作用:

using ResponseCallback = void (std::string const&);
Run Code Online (Sandbox Code Playgroud)

我从Visual Studio 2013收到一条含糊不清的错误消息,如下所示:

错误C2061:语法错误:标识符'字符串'

Sly*_*yps 5

但是你可以把它包起来.

template < typename P1 >
using ResponseCallback = 
typename std::remove_pointer < void (*)( P1 const & ) >::type;
Run Code Online (Sandbox Code Playgroud)

我在VS2013上进行了测试,然后是coliru

或者像这样的简单伪装包装也会满足VS2013:

template < typename functype >
struct functype_wrapper
{
    typedef functype type;
};

//using ResponseCallback = void ( std::string const & ); // nope
using ResponseCallback = functype_wrapper < void ( std::string const & ) >::type; // oke
Run Code Online (Sandbox Code Playgroud)