mirror of
https://github.com/boostorg/iterator.git
synced 2025-05-11 21:43:54 +00:00
Added iterator constructor to allow const adaptor
from non-const adaptee. Changed make_xxx to pass iterators by-value to get arrays converted to pointers. Removed InnerIterator template parameter from indirect_iterator_generator. Rearranged parameters for make_filter_iterator [SVN r9050]
This commit is contained in:
parent
8a73dcd052
commit
a94c9d0db2
@ -12,6 +12,18 @@
|
|||||||
//
|
//
|
||||||
// Revision History:
|
// Revision History:
|
||||||
|
|
||||||
|
// 09 Feb 2001 Jeremy Siek
|
||||||
|
// Added iterator constructor to allow const adaptor
|
||||||
|
// from non-const adaptee.
|
||||||
|
//
|
||||||
|
// Changed make_xxx to pass iterators by-value to
|
||||||
|
// get arrays converted to pointers.
|
||||||
|
//
|
||||||
|
// Removed InnerIterator template parameter from
|
||||||
|
// indirect_iterator_generator.
|
||||||
|
//
|
||||||
|
// Rearranged parameters for make_filter_iterator
|
||||||
|
//
|
||||||
// 07 Feb 2001 Jeremy Siek
|
// 07 Feb 2001 Jeremy Siek
|
||||||
// Removed some const iterator adaptor generators.
|
// Removed some const iterator adaptor generators.
|
||||||
//
|
//
|
||||||
@ -416,6 +428,13 @@ public:
|
|||||||
policies().initialize(iter());
|
policies().initialize(iter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To allow construction of const adaptor from non-const adaptee.
|
||||||
|
template <class OtherIterator>
|
||||||
|
iterator_adaptor(const OtherIterator& it, const Policies& p = Policies())
|
||||||
|
: m_iter_p(it, p) {
|
||||||
|
policies().initialize(iter());
|
||||||
|
}
|
||||||
|
|
||||||
template <class OtherIter, class OtherTraits>
|
template <class OtherIter, class OtherTraits>
|
||||||
iterator_adaptor (const iterator_adaptor<OtherIter, Policies,
|
iterator_adaptor (const iterator_adaptor<OtherIter, Policies,
|
||||||
OtherTraits>& src)
|
OtherTraits>& src)
|
||||||
@ -601,7 +620,7 @@ public:
|
|||||||
template <class AdaptableUnaryFunction, class Iterator>
|
template <class AdaptableUnaryFunction, class Iterator>
|
||||||
inline typename transform_iterator_generator<AdaptableUnaryFunction,Iterator>::type
|
inline typename transform_iterator_generator<AdaptableUnaryFunction,Iterator>::type
|
||||||
make_transform_iterator(
|
make_transform_iterator(
|
||||||
const Iterator& base,
|
Iterator base,
|
||||||
const AdaptableUnaryFunction& f = AdaptableUnaryFunction())
|
const AdaptableUnaryFunction& f = AdaptableUnaryFunction())
|
||||||
{
|
{
|
||||||
typedef typename transform_iterator_generator<AdaptableUnaryFunction,Iterator>::type result_t;
|
typedef typename transform_iterator_generator<AdaptableUnaryFunction,Iterator>::type result_t;
|
||||||
@ -631,9 +650,9 @@ struct indirect_iterator_policies : public default_iterator_policies
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class OuterIterator, // Mutable or Immutable, does not matter
|
template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||||
// Mutable -> mutable indirect iterator; Immutable -> immutable indirect iterator
|
// Mutable reference and pointer type in traits class -> mutable indirect iterator;
|
||||||
class InnerIterator = typename boost::detail::iterator_traits<OuterIterator>::value_type,
|
// Immutable reference and pointer type in traits class -> immutable indirect iterator
|
||||||
class InnerTraits = boost::detail::iterator_traits<InnerIterator>
|
class InnerTraits = boost::detail::iterator_traits<typename boost::detail::iterator_traits<OuterIterator>::value_type>
|
||||||
>
|
>
|
||||||
class indirect_iterator_generator
|
class indirect_iterator_generator
|
||||||
{
|
{
|
||||||
@ -652,36 +671,38 @@ public:
|
|||||||
template <class OuterIterator, // Mutable or Immutable, does not matter
|
template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||||
class ConstInnerIterator, // Immutable
|
class ConstInnerIterator, // Immutable
|
||||||
class ConstInnerTraits = boost::detail::iterator_traits<ConstInnerIterator>,
|
class ConstInnerTraits = boost::detail::iterator_traits<ConstInnerIterator>,
|
||||||
class InnerIterator = typename boost::detail::iterator_traits<OuterIterator>::value_type,
|
class InnerTraits = boost::detail::iterator_traits<typename boost::detail::iterator_traits<OuterIterator>::value_type>
|
||||||
class InnerTraits = boost::detail::iterator_traits<InnerIterator>
|
|
||||||
>
|
>
|
||||||
struct indirect_iterator_pair_generator
|
struct indirect_iterator_pair_generator
|
||||||
{
|
{
|
||||||
typedef typename indirect_iterator_generator<OuterIterator,
|
typedef typename indirect_iterator_generator<OuterIterator,
|
||||||
InnerIterator, InnerTraits>::type iterator;
|
InnerTraits>::type iterator;
|
||||||
typedef typename indirect_iterator_generator<OuterIterator,
|
typedef typename indirect_iterator_generator<OuterIterator,
|
||||||
ConstInnerIterator, ConstInnerTraits>::type const_iterator;
|
ConstInnerTraits>::type const_iterator;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class OuterIterator, class InnerIterator, class InnerTraits>
|
// WARNING: Do not use the one argument version of
|
||||||
inline typename indirect_iterator_generator<OuterIterator, InnerIterator, InnerTraits>::type
|
// make_indirect_iterator() if the iterator is a builtin pointer type
|
||||||
make_indirect_iterator(OuterIterator outer, InnerIterator, InnerTraits)
|
// and if your compiler does not support partial specialization.
|
||||||
{
|
|
||||||
typedef typename indirect_iterator_generator
|
|
||||||
<OuterIterator, InnerIterator, InnerTraits>::type result_t;
|
|
||||||
return result_t(outer);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
|
||||||
template <class OuterIterator>
|
template <class OuterIterator>
|
||||||
inline typename indirect_iterator_generator<OuterIterator>::type
|
inline typename indirect_iterator_generator<OuterIterator>::type
|
||||||
make_indirect_iterator(OuterIterator outer)
|
make_indirect_iterator(OuterIterator base)
|
||||||
{
|
{
|
||||||
typedef typename indirect_iterator_generator
|
typedef typename indirect_iterator_generator
|
||||||
<OuterIterator>::type result_t;
|
<OuterIterator>::type result_t;
|
||||||
return result_t(outer);
|
return result_t(base);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tried to allow InnerTraits to be provided by explicit template
|
||||||
|
// argument to the function, but could not get it to work. -Jeremy Siek
|
||||||
|
template <class InnerTraits, class OuterIterator>
|
||||||
|
inline typename indirect_iterator_generator<OuterIterator, InnerTraits>::type
|
||||||
|
make_indirect_iterator(OuterIterator base, InnerTraits)
|
||||||
|
{
|
||||||
|
typedef typename indirect_iterator_generator
|
||||||
|
<OuterIterator, InnerTraits>::type result_t;
|
||||||
|
return result_t(base);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@ -728,6 +749,10 @@ struct reverse_iterator_generator
|
|||||||
Traits> type;
|
Traits> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// WARNING: Do not use the one template parameter version of
|
||||||
|
// make_reverse_iterator() if the iterator is a builtin pointer type
|
||||||
|
// and if your compiler does not support partial specialization.
|
||||||
|
|
||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
inline typename reverse_iterator_generator<Iterator>::type
|
inline typename reverse_iterator_generator<Iterator>::type
|
||||||
make_reverse_iterator(Iterator base)
|
make_reverse_iterator(Iterator base)
|
||||||
@ -747,6 +772,7 @@ make_reverse_iterator(Iterator base, Traits* = 0)
|
|||||||
return result_t(base);
|
return result_t(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Projection Iterators Adaptor
|
// Projection Iterators Adaptor
|
||||||
|
|
||||||
@ -799,7 +825,9 @@ struct projection_iterator_pair_generator {
|
|||||||
|
|
||||||
template <class AdaptableUnaryFunction, class Iterator>
|
template <class AdaptableUnaryFunction, class Iterator>
|
||||||
inline typename projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type
|
inline typename projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type
|
||||||
make_projection_iterator(Iterator iter, AdaptableUnaryFunction f)
|
make_projection_iterator(
|
||||||
|
Iterator iter,
|
||||||
|
const AdaptableUnaryFunction& f = AdaptableUnaryFunction())
|
||||||
{
|
{
|
||||||
typedef typename projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type result_t;
|
typedef typename projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type result_t;
|
||||||
return result_t(iter, f);
|
return result_t(iter, f);
|
||||||
@ -807,7 +835,9 @@ make_projection_iterator(Iterator iter, AdaptableUnaryFunction f)
|
|||||||
|
|
||||||
template <class AdaptableUnaryFunction, class Iterator>
|
template <class AdaptableUnaryFunction, class Iterator>
|
||||||
inline typename const_projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type
|
inline typename const_projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type
|
||||||
make_const_projection_iterator(Iterator iter, AdaptableUnaryFunction f)
|
make_const_projection_iterator(
|
||||||
|
Iterator iter,
|
||||||
|
const AdaptableUnaryFunction& f = AdaptableUnaryFunction())
|
||||||
{
|
{
|
||||||
typedef typename const_projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type result_t;
|
typedef typename const_projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type result_t;
|
||||||
return result_t(iter, f);
|
return result_t(iter, f);
|
||||||
@ -856,27 +886,38 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class Predicate, class Iterator, class Traits>
|
// WARNING: Do not use this three argument version of
|
||||||
inline typename filter_iterator_generator<Predicate, Iterator, Traits>::type
|
// make_filter_iterator() if the iterator is a builtin pointer type
|
||||||
make_filter_iterator(Iterator first, Iterator last, Predicate p, Traits)
|
// and if your compiler does not support partial specialization.
|
||||||
{
|
|
||||||
typedef filter_iterator_generator<Predicate, Iterator, Traits> Gen;
|
|
||||||
typedef typename Gen::policies_type policies_t;
|
|
||||||
typedef typename Gen::type result_t;
|
|
||||||
return result_t(first, policies_t(p, last));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
// If the Predicate argument "p" is left out, an explicit template
|
||||||
|
// argument for the Predicate is required, i.e.,
|
||||||
|
// make_filter_iterator<Predicate>(f, l).
|
||||||
template <class Predicate, class Iterator>
|
template <class Predicate, class Iterator>
|
||||||
inline typename filter_iterator_generator<Predicate, Iterator>::type
|
inline typename filter_iterator_generator<Predicate, Iterator>::type
|
||||||
make_filter_iterator(Iterator first, Iterator last, Predicate p)
|
make_filter_iterator(Iterator first, Iterator last, const Predicate& p = Predicate())
|
||||||
{
|
{
|
||||||
typedef filter_iterator_generator<Predicate, Iterator> Gen;
|
typedef filter_iterator_generator<Predicate, Iterator> Gen;
|
||||||
typedef typename Gen::policies_type policies_t;
|
typedef typename Gen::policies_type policies_t;
|
||||||
typedef typename Gen::type result_t;
|
typedef typename Gen::type result_t;
|
||||||
return result_t(first, policies_t(p, last));
|
return result_t(first, policies_t(p, last));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
// Supply the Traits type via an exaplicit template argument, i.e.,
|
||||||
|
// make_filter_iterator<Traits>(f, l).
|
||||||
|
//
|
||||||
|
// If the Predicate argument "p" is left out, an explicit template
|
||||||
|
// argument for the Predicate is also required, i.e.,
|
||||||
|
// make_filter_iterator<Traits, Predicate>(f, l).
|
||||||
|
template <class Traits, class Predicate, class Iterator>
|
||||||
|
inline typename filter_iterator_generator<Predicate, Iterator, Traits>::type
|
||||||
|
make_filter_iterator(Iterator first, Iterator last, const Predicate& p = Predicate(), Traits* = 0)
|
||||||
|
{
|
||||||
|
typedef filter_iterator_generator<Predicate, Iterator, Traits> Gen;
|
||||||
|
typedef typename Gen::policies_type policies_t;
|
||||||
|
typedef typename Gen::type result_t;
|
||||||
|
return result_t(first, policies_t(p, last));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
Loading…
x
Reference in New Issue
Block a user