Prompted by a Stack Overflow article :-

    
http://stackoverflow.com/questions/17332749/vs2013-fails-with-variadic-template-specialization/

There seems to be anomalies between GCC 4.8.1's 0x11 implementation
and the standard.

It shows the code :-

    template <typename Sig, Sig& S> struct OpF;

    template <typename TR, typename ... Ts, TR (&f)(Ts...)> struct
OpF<TR (Ts...), f> { };

    int foo(int x) { return 0; }

    OpF<int (int), foo> f;


Given the C++ Standard outlaws this code, see 14.1 paragraphs 11 and 15.

Note that GCC accepts the following code with either -std=gnu++11 or
-std=c++11, the latter should be strict to the standard. Also given
these paragraphs were in the draft C++ standard too.

On the other hand GCC 4.8.1 will not accept a simple trailing 'int'
parameter after a variadic template list.

     template < typename TR, typename ... Ts, int i> TR tester(Ts...);
// error: parameter pack ‘Ts’ must be at the end of the template
parameter list

There seems to be quite an inconsistency even in an augmentation to
the standard.

On a personal note both these forms are syntactically correct but not
semantically by the standard, given that this is just a simple type
based pattern matching problem as far as I can see it would be nice to
have it within the language as it seems to fit naturally with
requirements.

Regards,

Aaron

Reply via email to