stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Lemings" <>
Subject RE: __rw_and (Was RE: Some internal aliases for __rw_integral_constant?)
Date Thu, 26 Jun 2008 18:09:22 GMT

> -----Original Message-----
> From: Martin Sebor [] On Behalf Of Martin Sebor
> Sent: Thursday, June 26, 2008 11:31 AM
> To:
> Subject: Re: __rw_and (Was RE: Some internal aliases for 
> __rw_integral_constant?)
> 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?

Yes, simplifying compile-time expressions by using it in either context
would be one reason, e.g.:

	template <class T, int I>
	struct S :
	    __rw_and<std::is_class<T>, 0 != I> {}; // explicit/finite

	template <class... T> struct O {
	    template <class... U> struct I
	        : __rw_and<std::is_convertible<T, U>::value...> {}; //
variable arguments

The other reason is portability.  Case in point.  Travis recently ran
into a problem where the compiler rejected a simple constant expression
like `sizeof (T) < sizeof (U)' but worked with the metafunction
equivalent of `__rw_less_than<sizeof (T), sizeof (U)>::value'.


View raw message