Date
2009-10-16.00:00:00
Message id
2396

Content

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; }

     private:
       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.