69 lines
2.5 KiB
Markdown
69 lines
2.5 KiB
Markdown
[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.5 Initializers"), 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.2 Conversion 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.4 Class members"))
|
||
to be bound to the first parameter of a constructor
|
||
where the parameter is of type
|
||
âreference to *cv2* Tâ
|
||
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*]
|