This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 121a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2026-10-16


3234. explicit and eligible constructors

Section: 11.4.4  [special]     Status: tentatively ready     Submitter: Jason Merrill     Date: 2026-09-30

Consider:

  template <class T>
  struct X {
    X() = default;
    X(const X&) = default;
  private:
    explicit X(const X&) requires (T::value) = default;  // #1
  };

  struct S { static constexpr bool value = true; };

  int main() {
    const X<S> x;
    X<S> x2 = x;     // #2
  }

According to 11.4.4 [special] paragraph 6, the public copy constructor is not eligible, because #1 is more constrained. This causes it to be deleted (9.6.2 [dcl.fct.def.default] paragraph 5). Yet, the public copy constructor is selected by overload resolution when used at #2.

Proposed resolution (approved by CWG 2026-10-16):

Change in 11.4.4 [special] paragraph 6 as follows:

An eligible special member function is a special member function for which:

[ Example:

  template <class T>
  struct X {
    X() = default;
    X(const X&) = default;                         // #1
  private:
    explicit X(const X&) requires true = default;  // #2
  };

  int main() {
    X<int> x;
    X<int> x2 = x;     // OK, selects #1; both #1 and #2 are eligible
  }

-- end example]

CWG 2026-10-06

See also GCC bugzilla #127627.