Why is this syntax not allowed:
template<float&& value>
struct MyStruct{
float GetValue() { return value; }
};
MyStruct<12.1f> myFloat;
And we have to instead do this:
template<const float& value>
struct MyStruct{
float GetValue() { return value; }
};
extern constexpr float param = 12.1f;
MyStruct<param> myFloat;
I don't see any reason why the first should be forbidden.
The first syntax is far less clunky and the second syntax just makes it seem like the creators of c++ are just trying to make things difficult....So why is it like this?