From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11780 invoked by alias); 2 Feb 2004 18:30:20 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 11752 invoked from network); 2 Feb 2004 18:30:17 -0000 Received: from unknown (HELO smtp-relay-8.adobe.com) (192.150.22.8) by sources.redhat.com with SMTP; 2 Feb 2004 18:30:17 -0000 Received: from inner-relay-3.corp.adobe.com (inner-relay-3 [153.32.251.51]) by smtp-relay-8.adobe.com (8.12.10/8.12.10) with ESMTP id i12ITe6P016397; Mon, 2 Feb 2004 10:29:46 -0800 (PST) Received: from iplan-mn (iplan-mn.corp.adobe.com [130.248.25.5]) by inner-relay-3.corp.adobe.com (8.12.9/8.12.9) with ESMTP id i12ITdkq002842; Mon, 2 Feb 2004 10:29:40 -0800 (PST) Received: from mn-eljaypc.adobe.com (b-25-155.corp.adobe.com [130.248.25.155]) by iplan-mn.corp.adobe.com (iPlanet Messaging Server 5.2 Patch 1 (built Aug 19 2002)) with ESMTP id <0HSG00FIAZDFVX@iplan-mn.corp.adobe.com>; Mon, 02 Feb 2004 12:29:39 -0600 (CST) Date: Mon, 02 Feb 2004 18:30:00 -0000 From: Eljay Love-Jensen Subject: Re: Problem with templates and operator overloading In-reply-to: <1075740536.2151.17.camel@rhodes153dhcp82.ces.clemson.edu> X-Sender: eljay@iplan-mn.corp.adobe.com To: cgoodle@CLEMSON.EDU, gcc-help@gcc.gnu.org Message-id: <5.2.1.1.2.20040202122048.01477768@iplan-mn.corp.adobe.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-SW-Source: 2004-02/txt/msg00013.txt.bz2 Hi Casey, I recommend taking out your template operator entirely, and put in a specific: inline double operator * (double lhs, doubler rhs) { return rhs * lhs; } Or alternatively (and especially if your operator struct isn't mathematically oriented), avoid overloading operators entirely and use a method invocation instead. struct doubler { double calc(double val) { return 2.0 * val; } }; Or a functor invocation. struct doubler { double operator () (double val) { return 2.0 * val; } }; HTH, --Eljay