I have the following (not compilable) code:
template< size_t N >
void foo( std::array )
{
// Code, where \"N\" is used.
}
int main()
{
f
If using an initializer list is not a must, you can use variadic template parameter packs:
template
void foo_impl(array const&)
{
cout << __PRETTY_FUNCTION__ << endl;
}
template
auto foo(Vals&&... vals) {
foo_impl({ std::forward(vals)... });
}
you'd call it as follows:
foo(1,2,3,4,5);
This defers common type checks until the initialization point of std::array (unless you add some admittedly ugly asserts), so you probably should prefer Columbo's answer.