|
Boost Users : |
Subject: Re: [Boost-users] Range library suggestion
From: John M. Dlugosz (mpbecey7gu_at_[hidden])
Date: 2013-01-24 06:22:56
On 1/24/2013 3:59 AM, boost-users-request-at-lists.boost.org |Boost/Allow to home| wrote:
>
>> >I just added my second metafunction of the form is_range_of_X<T> for use
>> >with enable_if, and although the first one took some fiddleing to pass
>> >both compilers I was using, the second was a clone of the first with the
>> >name and type changed. So it really ought to be a general purpose
>> >is_range_of<Whatever, T> metafunction.
> I assume it it's simply something like
> is_same<typename mpl::eval_if< is_range<T>, range_value<T>, void>::type,
> Whatever>
I ended up with:
template <typename Flag, typename T>
struct is_range_of_MYTHING2 : boost::mpl::false_ { };
template <typename T>
struct is_range_of_MYTHING2<boost::mpl::true_, T> {
typedef typename boost::range_value<T>::type val_type; // chokes here if T is not
a range
typedef typename is_convertible<val_type, MYTHING>::type type;
};
template <typename T>
struct is_range_of_MYTHING : is_range_of_MYTHING2<typename
boost::has_range_iterator<T>::type, T>
{ };
I'm familiar enough with type_traits, but not with all of Boost MPL. Is eval_if a
lazy-evaluation for short circuiting the AND of the two tests?
---John
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net