gcc doesn't accept pack expansion in default template argument
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
.
上一篇: 伪造/ CSRF令牌与最新版本的ring / compojure?
下一篇: gcc不接受默认模板参数中的包扩展