I want to be able to pass an anonymous std::array of variable size to a constructor:
using namespace std;
template <size_t N>
struct A
{
array<string, N> const value;
A (array<string, N>&& v): value {v} {}
};
Trying to pass an anonymous array like this …
A a { { "hello", "there" } };
This results in the following error (using clang++):
error: no viable constructor or deduction guide for deduction of template arguments of 'A'
If I don’t use a template and specify the size of the array in the definition, it works:
struct A
{
array<string, 2> const value;
A (array<string, 2>&& v): value {v} {}
};
A a { { "hello", "there" } };
Is it possible to write a deduction guide for this case? If so, how?
If not, how else could I solve this problem?