[cfe-dev] parse bug?

Howard Hinnant hhinnant at apple.com
Fri Jul 13 09:44:57 PDT 2012


#include <type_traits>

template <typename, typename = std::true_type> 
struct is_comparable : public std::false_type { 
}; 

template <typename T> 
struct is_comparable<T, 
  typename std::is_convertible< 
    decltype(T() > T()), bool 
  >::type> : public std::true_type { 
}; 

clang++ -stdlib=libc++ -std=c++11 test.cpp
test.cpp:10:18: error: expected ')'
    decltype(T() > T()), bool 
                 ^
test.cpp:10:13: note: to match this '('
    decltype(T() > T()), bool 
            ^
1 error generated.

Should the compiler be able to interpret the '>' as a greater-than instead of a close-template-brace since we're inside of parentheses?

There's a report on comp.lang.c++.moderated that GCC 4.6.3 parses this.

Howard




More information about the cfe-dev mailing list