|
Boost : |
Subject: Re: [boost] [type_traits] Interest in is_iterator type trait?
From: pfultz2 (pfultz2_at_[hidden])
Date: 2014-08-19 11:02:27
Here's something that I have been using on C++03 compilers to check if its an
iterator. It is somewhat similar, except it checks additionally for
`reference` and `pointer`.
template<class T1 = void, class T2 = void, class T3 = void, class T4 =
void, class T5 = void>
struct holder
{
typedef void type;
};
template<class T, class X = void>
struct is_iterator
: boost::mpl::bool_<false>
{};
template<class T>
struct is_iterator<T*>
: boost::mpl::bool_<true>
{};
template<class Iterator>
struct is_iterator<Iterator, typename holder
<
typename Iterator::iterator_category,
typename Iterator::reference,
typename Iterator::pointer,
typename Iterator::value_type,
typename Iterator::difference_type
>::type >
: boost::mpl::bool_<true>
{};
> If there is interest, and John Maddock gives the OK, I'll write docs and
> integrate into type_traits, then submit a pull request.
I definately think it is something very useful to have. Perhaps, it should
go
in Boost.Iterator instead?
-- View this message in context: http://boost.2283326.n4.nabble.com/type-traits-Interest-in-is-iterator-type-trait-tp4666578p4666585.html Sent from the Boost - Dev mailing list archive at Nabble.com.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk