VS2012 SP1 (+ November package) errors of an unknown type (similar to C :: a (T && ...))

So, the ms compiler could not compile this file (like a wall like my home VS2012 SP1 (+ November)), and clang and modern gcc could . Can someone please tell me that C ++ 11 is missing in VS and are there any ways?

#include <iostream>
#include <utility>
#include <type_traits>

struct A {
    int x;

    void a() {
        std::cout << "an a! " << x << "\n";
    }
};

struct B {
    double x;

    double b(double k) {
        std::cout << "b! " << x << ", " << k << "\n";
        return x - k;
    }

    void b() {
        std::cout << "b! " << x << ", ?\n";
    }
};

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

int main() {
    A a {12};
    B b {24};

    C c (&a, &b);

    c.a();
    c.b();
    std::cout << c.b(2445) << std::endl;
}

Errors:

testvc.cpp
--\testvc.cpp(38) : error C2535: 'unknown-type C::a(T &&...)' : member function already defined or declared
        --\testvc.cpp(33) : see declaration of 'C::a'
--\testvc.cpp(47) : error C2535: 'unknown-type C::b(T &&...)' : member function already defined or declared
        --\testvc.cpp(42) : see declaration of 'C::b'
--\testvc.cpp(56) : error C2893: Failed to specialize function template 'unknown-type C::a(T &&...)'
        With the following template arguments:
        ''
--\testvc.cpp(57) : error C2893: Failed to specialize function template 'unknown-type C::b(T &&...)'
        With the following template arguments:
        ''
--\testvc.cpp(58) : error C2893: Failed to specialize function template 'unknown-type C::b(T &&...)'
        With the following template arguments:
        'int'
+1
source share
2 answers

[This answer has been updated. See EDIT at end of text]

I brought this to SSCCE :

#include <iostream>

struct A { A g(int) { return A(); } };
struct B { B g() { return B(); } };

struct C
{
    template<typename... Ts>
    auto f(Ts... ts) -> decltype(A().g(ts...)) 
    { std::cout << "f -> A" << std::endl; return A(); }

    template<typename... Ts>
    auto f(Ts... ts) -> decltype(B().g(ts...)) 
    { std::cout << "f -> B" << std::endl; return B(); }
};

int main()
{
    C c;
    c.f(1);
}

GCC 4.7.2 Clang 3.2 , VC11 - . , , VC11 SFINAE, decltype, , , .

, ++ 11 (14.8.2/7):

, . , , nontype , (.. ) sizeof, decltype , . [...]

SFINAE 14.8.2/8, :

, . - , , . [...] .

, " "? , " ":

. , / , .. " " .

, whatsovever. , VC11 .

, " ", decltype (_b_caller__).

, , , ( - decltype ,). , .

, VC11.

P.S.: Q & A SO , SFINAE , .

EDIT:

, , , , . .

, f() . 14.6/8 ++ 11:

[...] , , . [...]

, , ( ) . , VC11, , , ( , ).

+3

. , GCC CLANG SFINAE , ambiguos. : c.b(2445) , , , .

  • ,

    auto b<int>(int args)->decltype(_b_caller__(_first__, std::forward <int> (args))), , , _b_caller<A,int>, _first__->b(int). A b, .

  • ,

    auto b<int>(int args)->decltype(_b_caller__(_second__, std::forward <int> (args))) _b_caller<B,int>, , B b (double).

, Visual Studio . , SFINAE , , SFINAE .

: : SFINAE ?

+1

All Articles