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 ++?
c ++ c ++ 11 template-specialization type-alias
max66
source share