Files
cppdraft_translate/cppdraft/temp/deduct/conv.md
2025-10-25 03:02:53 +03:00

3.6 KiB

[temp.deduct.conv]

13 Templates [temp]

13.10 Function template specializations [temp.fct.spec]

13.10.3 Template argument deduction [temp.deduct]

13.10.3.4 Deducing conversion function template arguments [temp.deduct.conv]

1

#

Template argument deduction is done by comparing the return type of the conversion function template (call itP) with the type specified by the conversion-type-id of theconversion-function-id being looked up (call it A) as described in [temp.deduct.type].

If the conversion-function-id is constructed during overload resolution ([over.match.funcs]), the rules in the remainder of this subclause apply.

2

#

If P is a reference type, the type referred to by P is used in place of P for type deduction and for any further references to or transformations ofP in the remainder of this subclause.

3

#

IfA is not a reference type:

IfP is an array type, the pointer type produced by thearray-to-pointer standard conversion is used in place ofP for type deduction; otherwise,

IfP is a function type, the pointer type produced by thefunction-to-pointer standard conversion is used in place ofP for type deduction; otherwise,

IfP is a cv-qualified type, the top-level cv-qualifiers ofP's type are ignored for type deduction.

4

#

IfA is a cv-qualified type, the top-level cv-qualifiers ofA's type are ignored for type deduction.

IfA is a reference type, the type referred to byA is used for type deduction.

5

#

In general, the deduction process attempts to find template argument values that will make the deducedA identical toA.

However, certain attributes of A may be ignored:

  • (5.1)

    If the original A is a reference type, any cv-qualifiers of A (i.e., the type referred to by the reference).

  • (5.2)

    If the original A is a function pointer or pointer-to-member-function type with a potentially-throwing exception specification ([except.spec]), the exception specification.

  • (5.3)

    Any cv-qualifiers in A that can be restored by a qualification conversion.

These attributes are ignored only if type deduction would otherwise fail.

If ignoring them allows more than one possible deducedA, the type deduction fails.