Non-type template parameters are limited. Generally, they can use a constant INTEGER (including enumeration values) or a pointer to an external linked object.
Floating Point Numbers and class objects cannot be used as non-type template parameters:
Template <double VAT> // Error
Double process (Double V)
{
Return v * VAT;
};
Template <STD: string name> // Error
Class myclass {
......
};
Because the string text is an internal connection object, it cannot be used as a template argument.
Template <char const * Name>
Class myclass {
};
Myclass <"hello"> X; // error: String text "hello" is not allowed"
In addition, global pointers cannot be used as template parameters.
-------------- The following is for your reference -------------------
External link:
InCodeDeclared out-of-block or modified using extern const
Scope: ThisProgram.
Internal link:
Static or const modified
Scope: this file.
No link:
Automatic variables, register variables, declared in the code block using static.
Scope: code block.