I have a 3D vector template class and I want to add a normalize member function to it.
Normalizing a vector only makes sense, if they use floating point numbers.
I want to use the c++20 requires syntax with the std::floating_point concept.
template<typename Type>
class vector3 {
[...]
vector3& normalize() requires std::floating_point<Type> noexcept;
}
But the compiler (gcc 11.2.0) gives me an error
error: expected ';' at end of member declaration
242 | vector3& normalize() requires (std::floating_point<Type>) noexcept;
| ^
| ;
noexceptis part ofdeclarator, andrequires-clausemust come afterdeclarator(dcl.decl)so you need to write