incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Lemings" <Eric.Lemi...@roguewave.com>
Subject RE: __rw_and (Was RE: Some internal aliases for __rw_integral_constant?)
Date Wed, 25 Jun 2008 18:00:20 GMT
 

> -----Original Message-----
> From: Eric Lemings [mailto:Eric.Lemings@roguewave.com] 
> Sent: Wednesday, June 25, 2008 11:41 AM
> To: dev@stdcxx.apache.org
> Subject: __rw_and (Was RE: Some internal aliases for 
> __rw_integral_constant?)
> 
>  
> 
> > -----Original Message-----
> > From: Eric Lemings [mailto:Eric.Lemings@roguewave.com] 
> > Sent: Tuesday, June 24, 2008 6:01 PM
> > To: dev@stdcxx.apache.org
> > Subject: RE: Some internal aliases for __rw_integral_constant?
> > 
> >  
> > 
> > > -----Original Message-----
> > > From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of 
> > Martin Sebor
> > > Sent: Tuesday, June 24, 2008 5:11 PM
> > > To: dev@stdcxx.apache.org
> > > Subject: Re: Some internal aliases for __rw_integral_constant?
> > > 
> > > Eric Lemings wrote:
> > > >  
> > > > Propose adding the following defs (or something similar) to
> > > > <rw/_meta_help.h> primarily for our own convenience:
> > > >  
> > > > template <bool _Bool>
> > > > class __rw_bool_const: public __rw_integral_constant<bool, 
> > > _Bool> {};
> > > 
> > > I was going to suggest the same thing this morning when I noticed
> > > how pervasive __rw_integral_constant<bool, _Bool> seems to be in
> > > traits definitions (I count 41 occurrences) and thinking that it
> > > would make them less verbose. (With a different spelling of _Bool
> > > to avoid potential clashes with the C99 name.)
> > 
> > Good point.
> > 
> > > 
> > > I didn't because the only beneficiaries of the change would be us
> > > (a fairly small notational convenience) and I wasn't sure the cost
> > > in terms of the added complexity and compilation time was 
> worth it.
> > > I contemplated suggesting a macro for the same purpose instead but
> > > decided against it on the assumption that it probably wouldn't be
> > > very popular ;-) But now that the cat's out of the bag and you're
> > > asking about alternatives let me throw it out there:
> > > 
> > > #define _RWSTD_BOOL_CONST(B) _RW::__rw_integral_constant<bool, B>
> > > 
> > > Usage:
> > > 
> > >       _RW::__rw_bool_const<bool, false>
> > >    vs
> > >      _RWSTD_BOOL_CONST (false)
> > > 
> > 
> > Looks good to me.  I'll just add _RWSTD_BOOL_CONST for now.
> 
> Okay, another proposal for inclusion though this particular utility
> may be a stretch unless you understand variadic templates very well.
> 
> 	template <bool...>
> 	struct __rw_and;
> 
> 	template <>
> 	struct __rw_and<>: std::true_type {};
> 
> 	template <bool _Bool0, bool... _BoolN>
> 	struct __rw_and<_Bool0, _BoolN...>
> 	    : _RWSTD_BOOL_CONST (_Bool0 && __rw_and<_BoolN...>::value)
> {};

Actually that should probably be something like:

	: std::conditional<_Bool0, __rw_and<_BoolN...>,
                         std::false_type>

Assuming the compiler isn't smart enough to short-circuit such
instantiations already.

Brad.

Mime
View raw message