G ++ and clang ++ different behavior with an alias pattern

Trying to answer another question, I wrote the following code, which behaves differently in g ++ (6.3.0) and in clang ++ (3.8.1)

#include <iostream> #include <type_traits> template <typename> struct foo { }; template <typename T> using alias = foo<T>; template <template <typename...> class, template <typename...> class> struct bar : public std::false_type { }; template <template <typename...> class C> struct bar<C, C> : public std::true_type { }; int main() { // g++ print 1 // clang++ print 0 std::cout << bar<foo, alias>::value << std::endl; } 

g ++ prints 1 (i.e.: activates the bar structure of the <processing> foo and alias specialties equally) and clang ++ prints 0 (i.e.: activates the general construction of bar , i.e. treat foo and alias as different).

The question, as usual, is: who is right? g ++ or clang ++?

+8
c ++ c ++ 11 template-specialization type-alias
source share

No one has answered this question yet.

See similar questions:

8
Corresponding alias pattern as template argument

or similar:

3076
What are the differences between a pointer variable and a reference variable in C ++?
2101
What is the difference between #include <filename> and #include "filename"?
1643
Why can templates be implemented only in the header file?
787
What is the difference between "typedef" and "use" in C ++ 11?
366
Pretty Printed Containers STL STL
6
Forwarding a non-type argument causes different behavior in the variable template
5
g ++ and clang ++ (with lib ++) different behavior using template template template
4
class template alias
4
creating a public alias template that references a private function template fails (clang)
3
C ++ STL type_traits question

All Articles