I have the following compile error which cause I am failing to understand.
template<typename T>
concept floating_point = std::is_floating_point_v<T>;
auto add(const floating_point f1, const floating_point f2)
{
return f1+f2;
}
In the above vertion the compiler is complaining:
ssource>:6:16: error: expected 'auto' or 'decltype(auto)' after 'floating_point'
6 | auto add(const floating_point f1, const floating_point f2)
Wheras when I add the auto specifiers, all good.
auto add(const floating_point auto f1, const floating_point auto f2)
{
return f1+f2;
}
This one works fine.
So the question really is why do we need auto here? (The signature seems odd to me)
The second question is what is the difference in return types:
floating_point auto add(..) vs auto add(..) for the same function? (Both compile)