Skip to content

Commit 77a11f1

Browse files
committed
Add explaining comment
1 parent 9a00e2d commit 77a11f1

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎tests/unit/in_class_field_initializer.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ struct S {
1313
Inner d;
1414
};
1515

16+
// Boxed::tag is in-class initialized. However the default constructor is never
17+
// instantiated, only the explicit one is used.
18+
//
19+
// Because no default constructor is instantiated, the specialization does not
20+
// contain the in-class initializer. In Rust, the Default trait initializes
21+
// Boxed::tag with 0. This is correct because the C++ program never reads the
22+
// in-class initializer of Boxed::tag, hence Rust also does not read it.
1623
template <typename T> struct Boxed {
1724
T v = T();
1825
int tag = 7;

0 commit comments

Comments
 (0)