Created on 2009-10-16.00:00:00 last changed 130 months ago
[Voted into the WP at the March, 2011 meeting.]
Proposed resolution (November, 2010):
Change 6.8 [basic.types] paragraph 10 as follows:
A type is a literal type if it is:
a scalar type; or
a class type (Clause 11 [class])
withthat
a trivial copy constructor,
no non-trivial move constructor,has a trivial destructor,
a trivial default constructor oris an aggregate type (9.4.2 [dcl.init.aggr]) or has at least one constexpr constructorother than theor constructor template that is not a copy or move constructor, andhas all non-static data members and base classes of literal types; or
an array of literal type.
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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-03-03 00:00:00 | admin | set | status: fdis -> c++11 |
2011-04-10 00:00:00 | admin | set | messages: + msg3299 |
2011-04-10 00:00:00 | admin | set | status: ready -> fdis |
2010-11-29 00:00:00 | admin | set | messages: + msg3048 |
2010-11-29 00:00:00 | admin | set | status: drafting -> ready |
2010-08-23 00:00:00 | admin | set | status: open -> drafting |
2009-10-16 00:00:00 | admin | create |