Following code is compiled successfully with clang, but gcc fails:
struct fn
{
template <typename ... Args>
static constexpr bool call (Args ... ) { return true; }
};
template <typename ... T>
static constexpr bool f = false;
template <typename ... Ts, bool F = fn::call(f<Ts> ...)>
void hoge () {}
int main () {}
gcc 5.1.0 (-Wall -Wextra -std=c++14 -pedantic) says
prog.cc:10:52: error: expansion pattern 'f<Ts>' contains no argument packs
template <typename ... Ts, bool F = fn::call(f<Ts> ...)>
clang 3.6.0 and 3.5.0 gives no errors.
Am I and clang violating c++ rules or is this a gcc bug?
You haven't violated any rule. It appears to be a problem with GCC's support for variable templates, not only default arguments, because this adjustment works:
template <typename ... T>
struct f {
static constexpr bool v = false;
};
template <typename ... Ts, bool F = fn::call(f<Ts>::v ...)>
void hoge () {}
http://coliru.stacked-crooked.com/a/ff81b6ab052a748b
As far as I know, a variable template is equivalent to a class template wrapping a static member, so this shouldn't cause any problems besides needing to write the ::v
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With