我尝试编译simple C++11 code(我最初的目标是vs2010,并且也作为次要选择vs 2012)they say它应该编译并is compilable on some modern compilers
因此,我想知道如何编译包含以下结构的代码:

struct C {
    A *_first__;
    B *_second__;
     C(A * _first__, B * _second__):_first__(_first__), _second__(_second__) {
    } template < typename K, typename ... T > static auto _a_caller__(K * k, T && ... args)->decltype(k->a(std::forward < T > (args) ...)) {
    return k->a(std::forward < T > (args)...);
    }
    template < typename...T > auto a(T &&...args)->decltype(_a_caller__(_first__, std::forward < T > (args)...)) {
        return _a_caller__(_first__, std::forward < T > (args)...);
    }
    template < typename...T > auto a(T &&...args)->decltype(_a_caller__(_second__, std::forward < T > (args)...)) {
        return _a_caller__(_second__, std::forward < T > (args)...);
    }
    template < typename K, typename...T > static auto _b_caller__(K * k, T && ... args)->decltype(k->b(std::forward < T > (args) ...)) {
        return k->b(std::forward < T > (args)...);
    }
    template < typename...T > auto b(T &&...args)->decltype(_b_caller__(_first__, std::forward < T > (args)...)) {
        return _b_caller__(_first__, std::forward < T > (args)...);
    }
    template < typename...T > auto b(T &&...args)->decltype(_b_caller__(_second__, std::forward < T > (args)...)) {
        return _b_caller__(_second__, std::forward < T > (args)...);
    }
};


在vs 2010中,如果没有,在vs2012中?

最佳答案

VS2010和VS2012均不支持可变参数模板:http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx
尽管它们在VS2012 CTP中受支持:http://blogs.msdn.com/b/vcblog/archive/2012/11/02/visual-c-c-11-and-the-future-of-c.aspx

如果您打算使用CTP,也请参见Variadic Template in VS 2012 (Visual C++ November 2012 CTP)

关于c++ - VS2010,VS2012和C++ 11错误C2059:语法错误:“...”如何解决?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13875542/

10-13 02:31