myWallJSON
myWallJSON

Reputation: 9512

VS2010 and VS2012 and C++11 error C2059: syntax error : '...' how to get around?

I try to compile simple C++11 code (I primaraly target vs2010 and also as secondary option vs 2012) they say it shall compile and is compilable on some modern compilers And so I wonder how to compile code containing structs like:

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)...);
    }
};

In vs 2010 and if not possible there in vs2012?

Upvotes: 0

Views: 744

Answers (1)

SomeWittyUsername
SomeWittyUsername

Reputation: 18368

Variadic templates aren't supported neither in VS2010 nor in VS2012: http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx They are supported in VS2012 CTP though: http://blogs.msdn.com/b/vcblog/archive/2012/11/02/visual-c-c-11-and-the-future-of-c.aspx

Also see Variadic Template in VS 2012 (Visual C++ November 2012 CTP) if you intend to use the CTP.

Upvotes: 4

Related Questions