Skip to content

Commit 78e0a5d

Browse files
pbackusdlang-bot
authored andcommitted
Clarify requirements for struct copy constructors
This change replaces informal language with official terms, adds cross-references, and documents a previously-undocumented requirement. Fixes Issue 23382 - Non-template requirement for copy constructors is undocumented
1 parent 9dedff3 commit 78e0a5d

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

spec/struct.dd

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,24 @@ $(H3 $(LEGACY_LNAME2 StructCopyConstructor, struct-copy-constructor, Struct Copy
994994
$(P Copy constructors are used to initialize a `struct` instance from
995995
another `struct` of the same type.)
996996

997-
$(P A constructor declaration is a copy constructor declaration if and only if it is a constructor
998-
declaration that takes only one non-default parameter by reference that is
999-
of the same type as `typeof(this)`, followed by any number of default parameters:)
997+
$(P A constructor declaration is a copy constructor declaration if it meets
998+
the following requirements:)
999+
1000+
$(UL
1001+
$(LI It takes exactly one parameter without a
1002+
$(DDSUBLINK spec/function, function-default-args, default argument),
1003+
followed by any number of parameters with default arguments.)
1004+
1005+
$(LI Its first parameter is a
1006+
$(DDSUBLINK spec/function, ref-params, `ref` parameter).)
1007+
1008+
$(LI The type of its first parameter is the same type as
1009+
$(DDSUBLINK spec/type, typeof, `typeof(this)`), optionally with one or more
1010+
$(DDLINK spec/const3, Type Qualifiers, type qualifiers) applied to it.)
1011+
1012+
$(LI It is not a
1013+
$(DDSUBLINK spec/template, template_ctors, template constructor declaration).)
1014+
)
10001015

10011016
---
10021017
struct A

0 commit comments

Comments
 (0)