From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17065 invoked by alias); 30 Jan 2003 03:40:19 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 17057 invoked from network); 30 Jan 2003 03:40:19 -0000 Received: from unknown (HELO monty-python.gnu.org) (199.232.76.173) by 172.16.49.205 with SMTP; 30 Jan 2003 03:40:19 -0000 Received: from nat-pool-rdu.redhat.com ([66.187.233.200] helo=lacrosse.corp.redhat.com) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18e5YC-0004p8-00 for gcc@gcc.gnu.org; Wed, 29 Jan 2003 22:39:40 -0500 Received: from free.redhat.lsd.ic.unicamp.br (aoliva.cipe.redhat.com [10.0.1.10]) by lacrosse.corp.redhat.com (8.11.6/8.9.3) with ESMTP id h0U3cSg03977; Wed, 29 Jan 2003 22:38:28 -0500 Received: from free.redhat.lsd.ic.unicamp.br (localhost.localdomain [127.0.0.1]) by free.redhat.lsd.ic.unicamp.br (8.12.7/8.12.7) with ESMTP id h0U3cRUF009016; Thu, 30 Jan 2003 01:38:27 -0200 Received: (from aoliva@localhost) by free.redhat.lsd.ic.unicamp.br (8.12.7/8.12.7/Submit) id h0U3cREr009012; Thu, 30 Jan 2003 01:38:27 -0200 To: martin@xemacs.org Cc: gcc@gcc.gnu.org, Nathan Sidwell Subject: Re: C++ template parameter constraints References: <15928.36654.134741.187229@gargle.gargle.HOWL> From: Alexandre Oliva Organization: GCC Team, Red Hat Date: Thu, 30 Jan 2003 08:18:00 -0000 In-Reply-To: <15928.36654.134741.187229@gargle.gargle.HOWL> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-01/txt/msg01626.txt.bz2 On Jan 30, 2003, Martin Buchholz wrote: > http://m17n.org/martin/writings/template-parameter-constraints.html > (feedback desired) /me thinks the syntax for satisfying might be something like Modula3's `T1 < T2' constraint, used to indicate that type T1 must be the same or derived from T2. We could use something like: template ::satisfied> declaration; and then define the predicate template in such a way that satisfied is typedefed to T if T satisfies the predicate, and not defined at all otherwise. Another addition that I'd find useful for template meta-programming is an operator such as :?:, similar to :: but with the following additional properties: - its left-hand operand must be a template-dependent type name - if the address of an expression containing :?: is taken and it turns out that, for a particular instantiation of the template, the member does not exist, the result is NULL - a typename expression containing :?: that refers to a type member that does not exist in a given template name resolves to a new C++ type that, in the absence of a better name, will be called nosuchtype. - sizeof applied to nosuchtype is zero - Any typename expression referencing members of nosuchtype resolve to nosuchtype - Any expression involving data members of nosuchtype has type nosuchtype, and translates to a call of terminate() - Any expression involving function members of nosuchtype (operator functions included) succeed overload resolution, but performing the actual function call evaluates the arguments and calls terminate(). The idea is that such constructs be guarded by NULL- or zero-size tests and be optimized away, but still parse correctly. Comments? -- Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/ Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org} CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org} Free Software Evangelist Professional serial bug killer