incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: __rw_and (Was RE: Some internal aliases for __rw_integral_constant?)
Date Thu, 26 Jun 2008 18:32:24 GMT
Eric Lemings wrote:
>  
> 
>> -----Original Message-----
>> From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of Martin Sebor
>> Sent: Thursday, June 26, 2008 11:31 AM
>> To: dev@stdcxx.apache.org
>> 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
> arguments

I can't say I understand this use case. What's S meant to represent?
It looks like some sort of a type trait. If so, why isn't plain &&
sufficient?

     template <class T, int I>
     struct S:
         __rw_conditional<__rw_is_class<T>::value && 0 != I, T, ???>
     { };

(Or enable_if instead of conditional, depending on what you want
to do with S).

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

Same here.

> 	};
> 
> 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'.

This sounds like an argument for __rw_less_than, not for __rw_and.

Btw., I'm not opposed to __rw_and in principle. I just want to see
some of its uses and the rationale for it (in case there's a better
or simpler way of doing the same thing).

Martin

Mime
View raw message