I'm trying to compile the following C++14 code with GCC 5.4 (online example):
template<typename T>
struct traits {
template<typename X>
static constexpr bool vect = true;
};
template<typename T1, typename T2>
constexpr bool all_vect = traits<T1>::template vect<T2>;
bool something() {
return all_vect<void, double>;
}
But I got the following errors:
<source>: In instantiation of 'constexpr const bool all_vect<void, double>':
<source>:11:12: required from here
<source>:8:16: error: 'template<class X> constexpr const bool traits<void>::vect<X>' is not a function template
constexpr bool all_vect = traits<T1>::template vect<T2>;
^
<source>:8:16: error: 'vect<T2>' is not a member of 'traits<void>'
Compiler exited with result code 1
While I have no problems in GCC 6.1 or more or in clang 3.9 or more. But it's the same for all versions of GCC5 i've tried.
I do not find the reason for this ? Normally, GCC5 should be C++14 feature complete.
Is there a simple workaround for this problem in GCC5 still using variable templates ? I'd rather not go back to using simple traits since I'm converting all my traits to using variable templates.