Assume that there is a function which accepts several strings:
void fun (const std::initializer_list& strings) {
for(auto s : strings)
The second part is easier:
template
void foo () {
fun({Args::value...});
}
The first part is tricky, because static_assert
is a declaration, not an expression, so you'd have to expand the variadic pack within the first parameter. It may be easier just to let the call to fun
do the checking for you. Here's a sketch of how to do it with an auxiliary all
constexpr
function:
constexpr bool all() { return true; }
template constexpr bool all(bool first, Args&&... rest) {
return first && all(rest...);
}
template
void foo () {
static_assert(all(std::is_convertible::value...), "All Args must have a value");
fun({Args::value...});
}