This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114b. See for the official list.


981. Constexpr constructor templates and literal types

Section: 6.8  [basic.types]     Status: C++11     Submitter: Gabriel Dos Reis     Date: 16 October, 2009

[Voted into the WP at the March, 2011 meeting.]

6.8 [basic.types] paragraph 10 requires that a class have at least one constexpr constructor other than the copy constructor in order to be considered a literal type. However, a constexpr constructor template might be instantiated in such a way that the constexpr specifier is ignored (9.2.6 [dcl.constexpr] paragraph 5) . It is therefore not known whether a class with a constexpr constructor template is a literal type or not until the constructor template is specialized, which could mean that an example like

    struct IntValue {
      template<typename T>
        constexpr IntValue(T t) : val(t) { }

      constexpr intmax_t get_value() { return val; }

       intmax_t val;

is ill-formed, because it is an error to declare a member function (like get_value()) of a non-literal class to be constexpr (9.2.6 [dcl.constexpr] paragraph 6).

6.8 [basic.types] paragraph 10 should be revised so that either a constexpr constructor or constexpr constructor template allows a class to be a literal type.

Proposed resolution (November, 2010):

Change 6.8 [basic.types] paragraph 10 as follows:

A type is a literal type if it is:

This resolution also resolves issues 1071 and 1198.