Eric Lemings wrote:
>
>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)
>{};
>
>For example:
>
> template <class... _TypesT>
> struct tuple {
>
> template <class... _TypesU>
> struct __rw_is_compat
> : __rw_and<std::is_convertible<_TypesT,
>_TypesU>::value...> {
>
> static_assert (sizeof... (_TypesT) == sizeof...
>(_TypesU),
> "tuple sizes must be equal");
> };
>
> };
>
Interesting. I have seen similar utilities, but they usually took two
parameters, so I never really saw them as useful. This, on the other
hand, does seem useful.
I'm assuming you are considering a fallback implementation like I have
for aligned_union when variadic templates aren't supported.
>Here are some quick tests that I tried out on it:
>
> typedef tuple<char, int, long> T1;
> std::cout << T1::__rw_is_compat<char, short, int>::value
> << std::endl;
>
> std::cout << T1::__rw_is_compat<const char, const int, const
>long>::value
> << std::endl;
>
> std::cout << T1::__rw_is_compat<float, int, long>::value
> << std::endl;
>
> std::cout << T1::__rw_is_compat<void*, int, long>::value
> << std::endl;
>
> // fires the static assertion
> //std::cout << T1::__rw_is_compat<char, short>::value
> //<< std::endl;
>
>Might just save that one for later but worth posting at least. :)
>
>Brad.
>