Files
cppdraft_translate/cppdraft/over/match/copy.md
2025-10-25 03:02:53 +03:00

2.5 KiB
Raw Blame History

[over.match.copy]

12 Overloading [over]

12.2 Overload resolution [over.match]

12.2.2 Candidate functions and argument lists [over.match.funcs]

12.2.2.5 Copy-initialization of class by user-defined conversion [over.match.copy]

1

#

Under the conditions specified in [dcl.init], 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.

Overload resolution is used to select the user-defined conversion to be invoked.

[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.

— end note]

Assuming that “cv1€ is the type of the object being initialized, withT a class type, the candidate functions are selected as follows:

  • (1.1)

    The non-explicit constructors ([class.conv.ctor]) ofT are candidate functions.

  • (1.2)

    When the type of the initializer expression is a class type “cv S”, conversion functions are considered. The permissible types for non-explicit conversion functions areT and any class derived from T. When initializing a temporary object ([class.mem]) 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€, the permissible types for explicit conversion functions are the same; otherwise there are none.

2

#

In both cases, the argument list has one argument, which is the initializer expression.

[Note 2:

This argument will be compared against the first parameter of the constructors and against the object parameter of the conversion functions.

— end note]