- Title
- Literal class types and trivial default constructors
- Status
- c++11
- Section
- 6.9 [basic.types]
- Submitter
- Daniel Krügler
Created on 2010-06-02.00:00:00 last changed 152 months ago
Messages
Date: 2011-03-15.00:00:00
[Voted into the WP at the March, 2011 meeting.]
Date: 2010-11-15.00:00:00
Proposed resolution (November, 2010): This issue is resolved by the resolution of
issue 981.
Date: 2010-06-02.00:00:00
According to 6.9 [basic.types] paragraph 10, one of the
requirements for a literal class type is a trivial default constructor or at least one constexpr
constructor other than the copy or move constructor This rule has unfortunate consequences. For example, in
B is a literal type, even though it is impossible to
initialize a constant of that type. Conversely, in
D is not a literal type, even though it could be
initialized as an aggregate. It would be an improvement to replace the requirement for a
trivial default constructor with a requirement that the class be
an aggregate.
struct A { int x; };
struct B: A { int y; };
struct C {
int a, b;
constexpr C(int x, int y): a(x), b(y) { }
};
struct D {
int x;
C c;
};
| 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: + msg3300 |
| 2011-04-10 00:00:00 | admin | set | status: ready -> fdis |
| 2010-11-29 00:00:00 | admin | set | messages: + msg3049 |
| 2010-11-29 00:00:00 | admin | set | status: drafting -> ready |
| 2010-06-02 00:00:00 | admin | create | |