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

2024-12-19


2662. Example for member access control vs. overload resolution

Section: 11.8.1  [class.access.general]     Status: C++23     Submitter: Shafik Yaghmour     Date: 2022-12-02

[Accepted as a DR at the February, 2023 meeting.]

Issue 600 was resolved by P1787R6, but no example was added.

Proposed resolution (approved by CWG 2023-01-06):

Change in 11.8.1 [class.access.general] paragraph 4 as follows:

... When a using-declarator is named, access control is applied to it, not to the declarations that replace it. For an overload set, access control is applied only to the function selected by overload resolution.

[ Example:

  struct S {
    void f(int);
  private:
    void f(double);
  };

  void g(S* sp) {
    sp->f(2);    // OK, access control applied after overload resolution
  }

-- end example ]