
please wait
|
|
|
|
template < typename T > struct attribute { T val; explicit attribute( const T& value = T() ) : val(value) {} }; |
|
|
A non-type template-parameter shall have one of the following (optionally cv-qualified) types: — integral or enumeration type, — pointer to object or pointer to function, — lvalue reference to object or lvalue reference to function, — pointer to member, — std::nullptr_t. |
|
|
char const *
implicitly converted to a std::string when the constructor is explicit?attribute<long> style { WS_VISIBLE } ;
attribute<std::string> title { "Hello World!" } ;
is initialization;attribute<std::string> title ( "Hello World!" ) ;
attribute<std::string> title = "Hello World!" ;
would be an error because the constructor is explicit.std::string
is not allowed as a non-type template-parameter.JLBorges wrote: |
---|
A std::string is not allowed as a non-type template-parameter. |
|
|
|
|