Files
2025-10-25 03:02:53 +03:00

69 lines
2.5 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[over.match.copy]
# 12 Overloading [[over]](./#over)
## 12.2 Overload resolution [[over.match]](over.match#copy)
### 12.2.2 Candidate functions and argument lists [[over.match.funcs]](over.match.funcs#over.match.copy)
#### 12.2.2.5 Copy-initialization of class by user-defined conversion [over.match.copy]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L1059)
Under the conditions specified in [[dcl.init]](dcl.init "9.5Initializers"), as
part of a copy-initialization of an object of class type, a user-defined
conversion can be invoked to convert an initializer expression to the
type of the object being initialized[.](#1.sentence-1)
Overload resolution is used
to select the user-defined conversion to be invoked[.](#1.sentence-2)
[*Note [1](#note-1)*:
The conversion performed for indirect binding to a reference to a possibly
cv-qualified class type is determined in terms of a corresponding non-reference
copy-initialization[.](#1.sentence-3)
— *end note*]
Assuming that
“*cv1* T” is the type of the object being initialized, withT a class type,
the candidate functions are selected as follows:
- [(1.1)](#1.1)
The non-explicit constructors ([[class.conv.ctor]](class.conv.ctor "11.4.8.2Conversion by constructor")) ofT are candidate functions[.](#1.1.sentence-1)
- [(1.2)](#1.2)
When the type of the initializer expression is a class type
“cv S”,
conversion functions are considered[.](#1.2.sentence-1)
The permissible types for non-explicit conversion functions areT and any class derived from T[.](#1.2.sentence-2)
When initializing a temporary object ([[class.mem]](class.mem "11.4Class members"))
to be bound to the first parameter of a constructor
where the parameter is of type
“reference to *cv2*€
and the constructor is
called with a single argument in the context of
direct-initialization of an object of type “*cv3* T”,
the permissible types for explicit conversion functions are the same;
otherwise there are none[.](#1.2.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L1098)
In both cases, the argument list has one argument, which is the initializer
expression[.](#2.sentence-1)
[*Note [2](#note-2)*:
This argument will be compared against
the first parameter of the constructors and against the
object parameter of the conversion functions[.](#2.sentence-2)
— *end note*]