c++ - gcc doesn't accept pack expansion in default template argument -
following code compiled clang, 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 , 3.5.0 gives no errors.
am , clang violating c++ rules or gcc bug?
you haven't violated rule. appears problem gcc's support variable templates, not default arguments, because 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 know, variable template equivalent class template wrapping static member, shouldn't cause problems besides needing write ::v
.
Comments
Post a Comment