C++ Logo


Advanced search

Subject: A defect in the section Namespace member definitions of the Standard Draft #N4820
From: Vladimir Grigoriev (vlad.moscow_at_[hidden])
Date: 2019-11-06 09:05:19

In the paragraph #3 of the section " Namespace member definitions: there is the following example relative to friend function declarations.

namespace A {
   class X {
      friend void f(X); // A::f(X) is a friend
      class Y {
         friend void g(); // A::g is a friend
         friend void h(int); // A::h is a friend
                                    // ::h not considered
         friend void f2<>(int); // ::f2<>(int) is a friend

// A::f, A::g and A::h are not visible here X x;
void g() { f(x); } // definition of A::g
void f(X) { /* ... */ } // definition of A::f

However the definition of the friend function g is incorrect because the friend function f is not yet visible 

I think the definitions should be exchanged

void f(X) { /* ... */ } // definition of A::f
void g() { f(x); } // definition of A::g 

With best regards,
(Vlad from Moscow)

You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups