|
Boost Users : |
Subject: [Boost-users] is_range / is_range_of metafunctions
From: Duncan Smith (duncanphilipnorman_at_[hidden])
Date: 2010-06-24 14:12:08
I'm using the Boost.Range 2.0 library (Boost version 1.43.0), and I
was looking for metafunctions to use in conjunction with
boost::enable_if. I wasn't able to find anything akin to "is_range"
and/or "is_range_of" in Boost.Range or in Boost.TypeTraits.
Here is a demonstrative example that uses "is_range_of":
class Y, Z;
class X
{
struct enabler {};
public:
// Construct from a range of Y.
template <class Range>
X(const Range &r,
typename boost::enable_if
< typename boost::is_range_of<Range, Y>::type
, enabler
>::type = enabler())
{ /* ... */ }
// Construct from a range of Z.
template <class Range>
X(const Range &r,
typename boost::enable_if
< typename boost::is_range_of<Range, Z>::type
, enabler
>::type = enabler())
{ /* ... */ }
};
Did I overlook something? Is there an easy way to get this effect?
I did find an email in the archives with an implementation of this
functionality:
http://lists.boost.org/Archives/boost/2007/08/125851.php
That implementation works for me. Is there a reason they have not
been included?
Thanks for any guidance,
Duncan
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