From Jason Turner

[class.ctor.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp8r7i36m4/{from.md → to.md} +84 -0
tmp/tmp8r7i36m4/{from.md → to.md} RENAMED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### General <a id="class.ctor.general">[[class.ctor.general]]</a>
2
+
3
+ A *declarator* declares a *constructor* if it is a function declarator
4
+ [[dcl.fct]] of the form
5
+
6
+ ``` bnf
7
+ ptr-declarator '(' parameter-declaration-clause ')' noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ
8
+ ```
9
+
10
+ where the *ptr-declarator* consists solely of an *id-expression*, an
11
+ optional *attribute-specifier-seq*, and optional surrounding
12
+ parentheses, and the *id-expression* has one of the following forms:
13
+
14
+ - in a friend declaration [[class.friend]], the *id-expression* is a
15
+ *qualified-id* that names a constructor [[class.qual]];
16
+ - otherwise, in a *member-declaration* that belongs to the
17
+ *member-specification* of a class or class template, the
18
+ *id-expression* is the injected-class-name [[class.pre]] of the
19
+ immediately-enclosing entity;
20
+ - otherwise, the *id-expression* is a *qualified-id* whose
21
+ *unqualified-id* is the injected-class-name of its lookup context.
22
+
23
+ Constructors do not have names. In a constructor declaration, each
24
+ *decl-specifier* in the optional *decl-specifier-seq* shall be `friend`,
25
+ `inline`, `constexpr`, `consteval`, or an *explicit-specifier*.
26
+
27
+ [*Example 1*:
28
+
29
+ ``` cpp
30
+ struct S {
31
+ S(); // declares the constructor
32
+ };
33
+
34
+ S::S() { } // defines the constructor
35
+ ```
36
+
37
+ — *end example*]
38
+
39
+ A constructor is used to initialize objects of its class type.
40
+
41
+ [*Note 1*: Because constructors do not have names, they are never found
42
+ during unqualified name lookup; however an explicit type conversion
43
+ using the functional notation [[expr.type.conv]] will cause a
44
+ constructor to be called to initialize an object. The syntax looks like
45
+ an explicit call of the constructor. — *end note*]
46
+
47
+ [*Example 2*:
48
+
49
+ ``` cpp
50
+ complex zz = complex(1,2.3);
51
+ cprint( complex(7.8,1.2) );
52
+ ```
53
+
54
+ — *end example*]
55
+
56
+ [*Note 2*: For initialization of objects of class type see 
57
+ [[class.init]]. — *end note*]
58
+
59
+ An object created in this way is unnamed.
60
+
61
+ [*Note 3*: [[class.temporary]] describes the lifetime of temporary
62
+ objects. — *end note*]
63
+
64
+ [*Note 4*: Explicit constructor calls do not yield lvalues, see 
65
+ [[basic.lval]]. — *end note*]
66
+
67
+ [*Note 5*: Some language constructs have special semantics when used
68
+ during construction; see  [[class.base.init]] and 
69
+ [[class.cdtor]]. — *end note*]
70
+
71
+ A constructor can be invoked for a `const`, `volatile` or `const`
72
+ `volatile` object. `const` and `volatile` semantics [[dcl.type.cv]] are
73
+ not applied on an object under construction. They come into effect when
74
+ the constructor for the most derived object [[intro.object]] ends.
75
+
76
+ The address of a constructor shall not be taken.
77
+
78
+ [*Note 6*: A `return` statement in the body of a constructor cannot
79
+ specify a return value [[stmt.return]]. — *end note*]
80
+
81
+ A constructor shall not be a coroutine.
82
+
83
+ A constructor shall not have an explicit object parameter [[dcl.fct]].
84
+