From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14756 invoked by alias); 23 Apr 2003 23:46:56 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 14749 invoked from network); 23 Apr 2003 23:46:55 -0000 Received: from unknown (HELO dberlin.org) (69.3.5.6) by sources.redhat.com with SMTP; 23 Apr 2003 23:46:55 -0000 Received: from [192.168.1.31] (account dberlin HELO dberlin.org) by dberlin.org (CommuniGate Pro SMTP 4.1b4) with ESMTP-TLS id 3691837; Wed, 23 Apr 2003 19:46:55 -0400 Date: Thu, 24 Apr 2003 01:13:00 -0000 Subject: Re: [RFA] handling of 'operator' in cp_find_first_component Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: Daniel Jacobowitz , gdb-patches@sources.redhat.com To: David Carlton From: Daniel Berlin In-Reply-To: Message-Id: Content-Transfer-Encoding: 7bit X-SW-Source: 2003-04/txt/msg00458.txt.bz2 On Wednesday, April 23, 2003, at 07:27 PM, David Carlton wrote: > On Tue, 22 Apr 2003 10:33:05 -0400, Daniel Berlin > said: > >> To answer whether you need the return type, let's add two >> specializations here and make it worse: > >> template <> long foo (int a) >> { >> return 9; >> } >> template <> int foo (int a) >> { >> return 10; >> } > > Yeah, but that's illegal, isn't it? You can't have two functions that > differ only in return type: otherwise, how would the compiler know > which one to use in a call to foo? > > I tried it out in GCC; the above doesn't compile (I guess templates > with 0 parameters aren't legal), It's not a template, it's a specialization, i just didn't paste the right thing. template <> int foo (int a) { return 5; } template <> long foo (int a) { return 9; } is what that should be. You can have two templates that only differ in return type, and they become, when instantiated, two functions that only differ in return type. --Dan