The following is an excerpt from the book C++ Primer 5th edition (emphasis is mine):
A nontype parameter may be an integral type, or a pointer or (lvalue) reference to an object or to a function type. An argument bound to a nontype integral parameter must be a constant expression. Arguments bound to a pointer or reference nontype parameter must have static lifetime (Chapter 12, p. 450). We may not use an ordinary (nonstatic) local object or a dynamic object as a template argument for reference or pointer nontype template parameters. A pointer parameter can also be instantiated by nullptr or a zero-valued constant expression.
Right below this paragraph one can find this highlighted Note:
Template arguments used for nontype template parameters must be constant expressions.
Maybe I'm missing something, but I believe the Note is wrong, as nontype template parameters of a pointer or lvalue reference to an object or function type are not constant expressions.
Aucun commentaire:
Enregistrer un commentaire