Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #431

Question about argument-dependent-lookup for namespace-scope friend function

From neverhoodboy <xinjie.wang@gmail.com>
Newsgroups comp.std.c++
Subject Question about argument-dependent-lookup for namespace-scope friend function
Date 2012-03-04 14:25 -0800
Organization http://groups.google.com
Message-ID <fc3ca60e-4998-45f9-9da4-ff26cca65005@q8g2000pbe.googlegroups.com> (permalink)

Show all headers | View raw


We know that argument-dependent-lookup can be used to find namespace-
scope friend function defined in some class which is otherwise not
visible using an ordinary lookup.  My question is, can the argument be
of some class in the same namespace other the enclosing class of the
friend function?  Please see the following code snippet:

namespace NNN
{
   class BBB {};
   class AAA
   {
   public:
       friend void func() {}
       friend void funca(AAA&) {}
       friend void funcb(BBB&) {}
   };
}

int main()
{
   NNN::AAA a;
   NNN::BBB b;
   NNN::func();  // this will fail to compile for sure
   funca(a);  // this will compile with no problem because of ADL
   funcb(b);  // will this compile?
}


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextNext in thread | Find similar


Thread

Question about argument-dependent-lookup for namespace-scope friend function neverhoodboy <xinjie.wang@gmail.com> - 2012-03-04 14:25 -0800
  Re: Question about argument-dependent-lookup for namespace-scope friend function Daniel Krügler<daniel.kruegler@googlemail.com> - 2012-03-06 08:50 -0800

csiph-web