Relative Content

Tag Archive for c++private-membersinvariantsnon-type-template-parameter

Why are non-type template parameters limited to structural types?

When using non-type template parameters, the non-type parameter must be ‘structural’ per the C++ standard. Classes with private data members are not structural. However, sometimes it is convenient to use private data members to protect a class invariant. Having a ‘structural’ restriction seems too restrictive. Consider the following code: