Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 6243 invoked from network); 30 May 2008 23:54:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 May 2008 23:54:01 -0000 Received: (qmail 54070 invoked by uid 500); 30 May 2008 23:54:03 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 54050 invoked by uid 500); 30 May 2008 23:54:03 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 54039 invoked by uid 99); 30 May 2008 23:54:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 May 2008 16:54:03 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of msebor@gmail.com designates 66.249.82.237 as permitted sender) Received: from [66.249.82.237] (HELO wx-out-0506.google.com) (66.249.82.237) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 May 2008 23:53:14 +0000 Received: by wx-out-0506.google.com with SMTP id i30so75061wxd.2 for ; Fri, 30 May 2008 16:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=7sHegfDT4G3JcwvVM0KYBrEk49ld6oeGNqDVBYnratY=; b=f0K8g4ygr13oarzmMOd31iUj91tWL6sqmvl4XUmdMDVIOYj2PuiLp4H0XYo+C4P4kIub48tCYiv6eakSZZgxXA/mqakdAJv4Reg1jdjyN8zEvQpHcNJF/a6/MBVE6QWR2VFv/IfAvGJqRgT7/9M56seefN/X848BOq1EPk4WFyQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=GXK7TIJ3Y6iS8GmrtbpTLtJy3+wo4d8Tyr/8PQUvB8j1cl/aKJl0JcfIEAyPnPsXsNYZQBLQ5/aO5U8oY3Rww/8r2EZ2KFWWhiCKK7lPNsLkZCi9DtlJDjI3Bxr773wkxOrVZCWinNSnsb1NZ97/tyq9Jm5yUBm+4MHuXBjQPrs= Received: by 10.90.94.2 with SMTP id r2mr6780299agb.46.1212191610454; Fri, 30 May 2008 16:53:30 -0700 (PDT) Received: from localhost.localdomain ( [71.229.200.170]) by mx.google.com with ESMTPS id y78sm1801811pyg.17.2008.05.30.16.53.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 30 May 2008 16:53:29 -0700 (PDT) Message-ID: <48409378.3010407@roguewave.com> Date: Fri, 30 May 2008 17:53:28 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Thunderbird 2.0.0.14 (X11/20080501) MIME-Version: 1.0 To: dev@stdcxx.apache.org Subject: Re: type_traits progress References: <483B79A1.4070808@roguewave.com> <483C67BA.6070209@roguewave.com> <48401E00.2090709@roguewave.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Martin Sebor X-Virus-Checked: Checked by ClamAV on apache.org Travis Vitek wrote: [...] >> Right. That could be another wrinkle. Our traits won't >> work with generic code that takes integral_constant >> by reference. > > I don't really see the motivation, but it is obvious that the committee > thought it was important for the standard traits to do so, so we should > probably follow suit in our internal implementation. > > If we did decide to do this then we would probably want our own write > __rw_integral_constant and use that internally to avoid namespace > pollution? Then I'd assume we'd want something like the following > example for is_const... Yes, I think this is close to what we want. The only thing that bugs me about it is... > > template > struct __rw_integral_constant > { > static const T value = v; > typedef T value_type; > typedef integral_constant type; ...this backward dependency on integral_constant, but I don't see how to break it without template typedefs. I don't think there's a compiler out there that supports them yet. > }; > > template > struct __rw_is_const_impl > { > enum { _C_value = 0 }; > }; > > template > struct __rw_is_const_impl > { > enum { _C_value = 1 }; > }; > > template > struct __rw_is_const > : __rw_integral_constant::_C_value> > { > }; > > template > struct integral_constant : __rw_integral_constant > { > }; > > template > struct is_const : integral_constant::value> > { > }; > >>>> Another, and probably far more important reason for keeping the >>>> names of the members the same, to make our implementation traits >>>> look and feel like standard traits, i.e., conform to the traits >>>> requirements. Otherwise the rest of our library won't be able >>>> to easily use the private traits. >>> But this should only be an issue if we are passing around traits as >>> template parameters, right? >> Right. >> >>> All of the scenerios I can think of we would be using >> __rw_enable_if or >>> specialization on non-type template parameters. Can you think of any >>> case where the name of the member would be important? >> I searched the latest draft standard to see if traits were >> being used anywhere in the spec but didn't get any hits. >> >> I hadn't thought too deeply about how the traits could be >> used, but I have used traits outside of enable_if. I think >> its should be easy to contrive code that wouldn't work with >> our approach. Let me try: >> >> // transforms T if it satisfies Property >> // by applying Transformer, otherwise leaves >> // T unchanged: >> >> template > template Property, >> template Transformer> >> struct TransformIf; > > Yes, if we go with the above approach then this problem just disappears > for any trait inheriting from __rw_integral_constant. For the other > types I can just expose the names that the standard defines. > > I'm okay with that if you think that the motivation is there. I'm not sure the contrived example I gave qualifies as a motivating use case but it is a use case nonetheless. That said, I don't think consistency with other uglified names is a compelling enough reason for us to dismiss even this contrived use case. Martin