【发布时间】:2019-12-10 02:56:21
【问题描述】:
如果我有一个可变参数模板;
template<typename T>
concept Fooable = requires (T t) { t.bar() -> bool; };
struct Foo {
int big_foo;
template<std::Integral T, Fooable ... U>
explicit Foo(T&& i, U&& ... f) noexcept
: big_foo {std::forward<T>(i)}
{
Something::something(std::forward<U>(f)...);
...
}
};
然后模板的定义及其约束按预期工作。
但如果我“要求”更多对 Foo 的约束,因此使用“要求”表达式格式,例如;
template<typename T, typename ... U>
requires std::Integral<T>
&& Fooable<U> && BillyBobable<U> // WHAT GOES HERE? ELLIPSIS... BUT WHERE?
explicit Foo(T&& i, U&& ... f) noexcept
: big_foo {std::forward<T>(i)}
{
SOMETHING::something(std::forward<U>(f)...);
...
}
那么:我应该使用什么语法作为可变参数U 在表达式中展开它?
【问题讨论】:
标签: c++ variadic-templates c++20 c++-concepts