From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 27 16:15:58 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15F2116A421 for ; Thu, 27 Dec 2007 16:15:58 +0000 (UTC) (envelope-from oceanare@pacific.net.sg) Received: from smtpgate1.pacific.net.sg (smtpgate1.pacific.net.sg [203.120.90.31]) by mx1.freebsd.org (Postfix) with SMTP id 3DC4F13C448 for ; Thu, 27 Dec 2007 16:15:56 +0000 (UTC) (envelope-from oceanare@pacific.net.sg) Received: (qmail 6362 invoked from network); 27 Dec 2007 16:15:55 -0000 Received: from adsl117.dyn229.pacific.net.sg (HELO P2120.somewherefaraway.com) (oceanare@210.24.229.117) by smtpgate1.pacific.net.sg with ESMTPA; 27 Dec 2007 16:15:55 -0000 Message-ID: <4773CFB6.8020008@pacific.net.sg> Date: Fri, 28 Dec 2007 00:15:50 +0800 From: Erich Dollansky User-Agent: Thunderbird 2.0.0.6 (X11/20070826) MIME-Version: 1.0 To: "Heiko Wundram (Beenic)" References: <200712271621.12167.wundram@beenic.net> <4773C7E5.3090302@pacific.net.sg> <200712271701.38821.wundram@beenic.net> In-Reply-To: <200712271701.38821.wundram@beenic.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: OT: C++ Template Functions X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Dec 2007 16:15:58 -0000 Hi, Heiko Wundram (Beenic) wrote: > Am Donnerstag, 27. Dezember 2007 16:42:29 schrieb Erich Dollansky: >> Heiko Wundram (Beenic) wrote: >>> The problem is most probably related to the fact that the group of member >>> functions is only discriminated by return type (i.e., the template >>> parameter defines the return type), not by parameter (which could be >>> inferred). >> if nothing got changed over the last years, it is not possible to do >> this by definition. >> >> When I needed this the last time, I used a enum as an additonal >> parameter to achieve this. >> >> I know, it is not perfect, but it leads to what I intended. >> >> It should work here too. I know, it is not the prefect solution. > > This is perfectly possible (nowadays? I've been using this for quite some time > now, but not in the "complexity" of the original mail). Take the following > code, for example, which compiles perfectly fine with gcc (and works, of > course): > > """ > template > T* newop(U test) > { > return new T(test); > } > wasn't your question that you have a class with several member functions which would all be identical except of the return type? It is not a problem outside a class, the problem comes when you want to do this inside a class as you also would define a class with an - in theory - unknown and unlimited number of member functions. Erich