From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11915 invoked by alias); 10 Jun 2008 19:05:51 -0000 Received: (qmail 11906 invoked by uid 22791); 10 Jun 2008 19:05:51 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 10 Jun 2008 19:05:31 +0000 Received: from zps77.corp.google.com (zps77.corp.google.com [172.25.146.77]) by smtp-out.google.com with ESMTP id m5AJ5LlS024443; Tue, 10 Jun 2008 20:05:21 +0100 Received: from localhost.localdomain.google.com (dhcp-172-18-116-187.corp.google.com [172.18.116.187]) (authenticated bits=0) by zps77.corp.google.com with ESMTP id m5AJ5KGZ007481 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 10 Jun 2008 12:05:20 -0700 To: Alan Mackenzie Cc: gcc@gcc.gnu.org Subject: Re: Help requested on C++ template syntax (for Emacs development). References: <20080610183707.GB4844@muc.de> From: Ian Lance Taylor Date: Tue, 10 Jun 2008 19:05:00 -0000 In-Reply-To: (Ian Lance Taylor's message of "Tue\, 10 Jun 2008 11\:56\:10 -0700") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2008-06/txt/msg00258.txt.bz2 Ian Lance Taylor writes: > Alan Mackenzie writes: > >> I'm thinking of things like >> >> foo (a < b, c > d); >> >> I think this is unambiguously a function call with 2 parameters, the >> expressions "a < b" and "c > d". It cannot be be one with 1 parameter >> beginning with the template invocation "a < b , c >". Or can it? > > No, it can't be, because a is a type. The result would be > foo(TYPE d), which can not be a function call. On the other hand, if > there were a type before foo then this would be a function > declaration. For example, this is valid C++ code: > > template class a; > > int fn(int d, int e) > { > const int b = 1; > const int c = 2; > typedef int f; > f foo (int, int); > f foo (a < b, c > d); > foo (e < b, c > d); > } > > The line "f foo (a < b, c > d);" uses a template, the line "foo (e < > b, c > d);" does not. Oh, wait, I forgot about constructors. This is valid C++ code: template class a; const int b = 1; const int c = 2; int d; int e; class foo { foo (a < b, c > d); }; extern void quux (int, int); void bar() { quux (e < b, c > d); } Inside the class foo, you've got a template, inside the function bar, you've got a function call. I think you're going to have a hard time with this. Ian