In the following code:
template<size_t N>
int b(int q, const std::array<int, N>& types)
{
int r = q;
for (int t : types)
{
r = r + t;
}
return r;
}
int main()
{
b<2>(9, { 2,3 });
}
How can I avoid having to specify 2 in the call to b for N? Why can't this type be automatically deduced? With out it I get the error:
'b': no matching overloaded function found 'int b(int,const std::array &)': could not deduce template argument for 'N'