Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 3149 invoked from network); 26 Jun 2008 17:31:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jun 2008 17:31:50 -0000 Received: (qmail 76246 invoked by uid 500); 26 Jun 2008 17:31:45 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 76231 invoked by uid 500); 26 Jun 2008 17:31:45 -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 76213 invoked by uid 99); 26 Jun 2008 17:31:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2008 10:31:45 -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 209.85.132.246 as permitted sender) Received: from [209.85.132.246] (HELO an-out-0708.google.com) (209.85.132.246) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2008 17:30:54 +0000 Received: by an-out-0708.google.com with SMTP id d33so23557and.97 for ; Thu, 26 Jun 2008 10:31:13 -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=sySQVKHA2gxF08gZx4gQW94/9luRCxhYwysPGi+NuQQ=; b=M2+aPPqxP/ceYHFkwLSFhUGr350Fy8raTTdXQxLYDxji2q58ZptiS1PfnbH4BEttVc 3LIUvOI/XrmHgp2qde5QNQLxDB5cJKmZWHYVA4Dr0HG6F22rlb8LMOyatKDJ4PDF/F0E YGGPCqcXF9fmwheHQa2AsvCTO63aY3+bolPJ4= 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=QhrAh8I0m90OwfrykN2oiF32MYxOVeFDrrBt17sDyoCahBSNpuwQAXBVXWSBQX6jyF bNg+aNdwOUzZ1sJUHF4ObYudjmaUzJwN9t72z4e1yYlr1TlbelJcuog0xa5f1YxojvHM JNPV6umqIDGhpuK//Epi2VrQOaOJ8rkpKNtzk= Received: by 10.100.225.19 with SMTP id x19mr209238ang.151.1214501473099; Thu, 26 Jun 2008 10:31:13 -0700 (PDT) Received: from localhost.localdomain ( [71.229.200.170]) by mx.google.com with ESMTPS id d35sm909406and.13.2008.06.26.10.31.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 26 Jun 2008 10:31:12 -0700 (PDT) Message-ID: <4863D25E.5070005@roguewave.com> Date: Thu, 26 Jun 2008 11:31:10 -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: __rw_and (Was RE: Some internal aliases for __rw_integral_constant?) References: <48617F0F.2020100@roguewave.com> <4863B97C.7050304@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 Eric Lemings wrote: > > >> -----Original Message----- >> From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of Martin Sebor >> Sent: Thursday, June 26, 2008 9:45 AM >> To: dev@stdcxx.apache.org >> Subject: Re: __rw_and (Was RE: Some internal aliases for >> __rw_integral_constant?) >> >> Eric Lemings wrote: >>> >> [...] >>> Okay, another proposal for inclusion though this particular utility >>> may be a stretch unless you understand variadic templates very well. >> Can you show what the code looks like w/o __rw_and for comparison? > > I could try but you would want to read it about as much as I would want > to write it. :) > > Basically, it would require all the hackery required for simulating > variadic templates. Not pretty. Maybe I misunderstood the purpose of the __rw_and template. I wasn't asking to see a solution w/o variadic templates, but one without __rw_and. If I understand your response correctly, you're proposing to add __rw_and to hide the dual implementation of ANDing variable numbers of constraints, one with variadic templates and the other without. I.e., __rw_and would be more than just syntactic sugar. Correct? > >> In general, an important design principle behind stdcxx is efficiency, >> both in time and in space. And in terms of time, both compilation as >> well runtime efficiency is important. In contrast to the ordinary >> kind, template metaprogramming tends to increase compilation times >> much more noticeably. In C++ 0x a good amount metaprogramming code >> is dictated by the standard already but as a rule we need exercise >> restraint when introducing templatized helper code, especially >> when template recursion is involved. > > Right. The way I see it, utilities like this are indended to simplify > the required metaprogramming code. In order to do that though, other > developers would have to reuse it. :) > > That's why I said at the bottom of the email that I'll probably hold off > on moving it up the chain of includes to a more generic header where it > would be more reusable until such a time when other developers find more > need for it. (I doubt tuples will be the only place requiring > compile-time logical operators.) But it's posted now so we're all aware > of it at least. I'm not sure what you mean by "moving it up the chain." Sounds to me like you need __rw_and to implement tuple and are asking if the template should be moved into some common header and made use of in other areas of the implementation. If that's the case, I agree that we definitely should reuse as many helpers as we can and avoid reinventing the wheel. > > BTW, is template recursion really costly in terms of compile times? I've never benchmarked it but it's a commonly held opinion that it is exceedingly costly, primarily because C++ compilers weren't designed with template metaprogramming in mind. You can take as anecdotal evidence the simple little example below which takes about 7 times longer to compile with gcc 4.3 when TEMPLATE is defined than when it isn't. The -fstats option also shows that the template cases uses up 2.5 time more memory. #ifdef TEMPLATE template struct sum { enum { v = N + sum::v }; }; template <> struct sum<0> { enum { v }; }; int N = sum<500>::v; #else int N = 500 + 499 + 498 + 497 + /* ... */ + 3 + 2 + 1 + 0; #endif Martin