2015-10-23 17 views
8

Myślę, że znalazłem inną sprzeczność pomiędzy lambdami a obiektami wywoływalnymi "clang vs gcc".clang vs gcc - pusty ogólny argument argumentacji argumentu lambda

decltype(l)::operator() powinna być równoważna C::operator(), ale jeśli o zmiennej liczbie argumentów paczka pozostanie puste w ogólnym lambda, gcc odmawia skompilować:

15 : error: no match for call to '(main()::) (int)' l(1);

15 : note: candidate: decltype (((main()::)0u).main()::(x,)) (*)(auto:1&&, auto:2&&, ...)

15 : note: candidate expects 3 arguments, 2 provided

14 : note: candidate: template main()::

auto l = [](auto&& x, auto&&...) { return x; };

14 : note: template argument deduction/substitution failed:

15 : note: candidate expects 2 arguments, 1 provided

l(1);

Live example on godbolt.org.

struct C 
{ 
    template<typename T, typename... TRest> 
    auto operator()(T&& x, TRest&&...){ return x; } 
}; 

int main() 
{ 
    // Compiles both with clang and gcc. 
    auto c = C{}; 
    c(1); 

    // Compiles with clang 3.7. 
    // Does not compile with gcc 5.2. 
    auto l = [](auto&& x, auto&&...) { return x; }; 
    l(1); 
} 

nie mógł znaleźć coś związane z tym na gcc bug tracker (nie spędzać zbyt dużo czasu na poszukiwanie chociaż) - gcc jest źle tutaj?

+1

Wygląda jak błąd w gcc. – 0x499602D2

Odpowiedz

1

Zgłosiłem problem jako błąd gcc #68071.

Powiązane problemy