The specializations of vector
class template for 2 and 3 template arguments have got static constexpr
data member value
of literal type (vector2
and vector3
, respectively) that don't have namespace scope definitions.
You'll need them because you odr-use value
when it binds to the reference parameter when passed to do_something
function.
§9.4.2/3 [class.static.mfct]
If a non-volatile
const static
data member is of integral or enumeration type, its declaration in the class definition can specify abrace-or-equal-initializer
in which everyinitializer-clause
that is anassignment- expression
is a constant expression (5.19). Astatic
data member of literal type can be declared in the class definition with theconstexpr
specifier; if so, its declaration shall specify abrace-or-equal-initializer
in which everyinitializer-clause
that is anassignment-expression
is a constant expression. [Note: In both these cases, the member may appear in constant expressions. —end note ] The member shall still be defined in a namespace scope if it is odr-used (3.2) in the program and the namespace scope definition shall not contain an initializer.
EDIT: Correcting myself, it's actualy some_wrapper<T>::value
that needs this definition (for the reason mentioned above, nonetheless). So what you need is this in namespace scope after the definition of some_wrapper
:
template<typename V>
constexpr typename V::vec_type some_wrapper<V>::value;
After that, your code compiles and runs.