I have this concept and template function
template<typename T>
concept Averageable = std::is_default_constructible<T>::value &&
requires(T a, T b)
{
{ a += b } -> std::convertible_to<T>;
{a / size_t(1)} -> std::convertible_to<T>;
};
template<typename T>
requires Averageable<T>
T mean(const T* vals, size_t size)
{
T sum();
for (size_t i{}; i < size; size++)
{
sum += vals[i];
}
return sum / size;
}
And for some reason calling like this
const int a[]{1,2,3};
const int res = mean<int>(a, 3);
results in the following IntelliSense error
no instance of function template matches the argument list argument types are: (size_t, int)
I'm using Visual Studio 2022 with c++ 20. I have tried searching for a reason why this is happening endlessly (as well as a proper tutorial for concepts) and have come up short.
I'm new to using concepts/requires so if anyone has any insight as to why this doesn't work or how to properly do it I would greatly appreciate it