From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22931 invoked by alias); 8 Apr 2009 09:38:56 -0000 Received: (qmail 22919 invoked by uid 22791); 8 Apr 2009 09:38:56 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,J_CHICKENPOX_43,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-fx0-f165.google.com (HELO mail-fx0-f165.google.com) (209.85.220.165) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 08 Apr 2009 09:38:49 +0000 Received: by fxm9 with SMTP id 9so32941fxm.8 for ; Wed, 08 Apr 2009 02:38:46 -0700 (PDT) Received: by 10.103.2.14 with SMTP id e14mr442991mui.41.1239183526344; Wed, 08 Apr 2009 02:38:46 -0700 (PDT) Received: from ?150.178.13.59? ([150.178.13.59]) by mx.google.com with ESMTPS id s10sm13248418mue.46.2009.04.08.02.38.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 08 Apr 2009 02:38:45 -0700 (PDT) Message-ID: <49DC70A4.6050705@gmail.com> Date: Wed, 08 Apr 2009 09:38:00 -0000 From: Fabio Tesser User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Ian Lance Taylor CC: gcc-help@gcc.gnu.org Subject: Re: different friend functions behaviour References: <49DB7311.10208@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2009-04/txt/msg00085.txt.bz2 Thanks for reply Ian. The Argument Dependent Lookup should be active even inside a template class? If I try put the friend function inside a template, g++ (version 4.3.2) gives me the following error: $ cat test_template_friend_function.cpp //////////////////////////////////// class test { public: friend void ftest2(test x) { } }; template class simple_template { public: void ftest3(T){ ftest2(test()); } }; int main(int argc, char *argv[]) { simple_template a; a.ftest3(0); } ///////////////////////////////////////// $ g++ test_template_friend_function.cpp test_template_friend_function.cpp: In member function ‘void simple_template::ftest3(T) [with T = int]’: test_template_friend_function.cpp:18: instantiated from here test_template_friend_function.cpp:12: error: no matching function for call to ‘ftest2(test)’ The same code compiles without errors with gcc version 4.2.4. In your opinion what is the correct behavior? Thanks Fabio On 04/07/2009 06:44 PM, Ian Lance Taylor wrote: > Fabio Tesser writes: > > >> The difference between the two friend functions is that the first has >> not any test class as argument while the second has a test class as >> argument. >> >> Is this the right behaviour? >> > > Yes, this is correct. This is Argument Dependent Lookup, also known as > Koenig lookup. > > http://en.wikipedia.org/wiki/Argument_dependent_lookup > > Ian >