Skip to content

CWG1699 Does befriending a class befriend its friends? #1573

@jensmaurer

Description

@jensmaurer

A friend declaration is a member-declaration, but it is not clear how far the granting of friendship goes in a friend declaration. For example:

  class c {
    class n {};
    friend struct s;
  };

  struct s {
    friend class c::n;          // #1
    friend c::n g();            // #2
    friend void f() { c::n(); } // #3
  };

In particular, if a friend function is defined inside the class definition, as in #3, does its definition have access to the private and protected members of the befriending class? Implementations vary on this point.

See CWG1699 for the full discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EWGEvolutionpaper neededAn issue needs a paper to describe its solution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions