Skip to content

[over.match.class.deduct] Inconsistent description of hypothetical function templates #738

@t3nsor

Description

@t3nsor

Full name of submitter: Brian Bi

Issue description: [dcl.type.class.deduct]/1 states: "[...] The placeholder is replaced by the return type of the function selected by overload resolution for class template deduction ([over.match.class.deduct])". However, [over.match.class.deduct]/5 states: "Initialization and overload resolution are performed as described in [dcl.init] and [over.match.ctor], [over.match.copy], or [over.match.list] [...] where the guides of the template named by the placeholder are considered to be the constructors of that class type for the purpose of forming an overload set [...]"

  1. Constructors do not have return types.
  2. The constructor formulation is also unclear as to whether the simple-template-id of a deduction-guide participates in SFINAE.
  3. Stating that initialization is performed is at odds with existing behavior of implementations, which do not check the semantic constraints of initialization. For example, all implementations treat class template argument deduction as successful in the below example, despite the private constructor of X:
template <class T>
struct S {
    S(...);
};

class X {
  private:
    X(int);
};

template <class T>
S(T, X) -> S<T>;

S s(1, 1);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions