mirror of
https://github.com/boostorg/iterator.git
synced 2025-07-03 07:46:41 +02:00
Compare commits
26 Commits
svn-branch
...
boost-1.25
Author | SHA1 | Date | |
---|---|---|---|
a2ed65f71d | |||
d1c7594344 | |||
ac327f51e9 | |||
4e18b11263 | |||
81e3df2b36 | |||
ac05307515 | |||
552a1e6785 | |||
134b8b51aa | |||
efecfd17b9 | |||
799158841e | |||
582ebfd054 | |||
42e4db1539 | |||
d7023154a3 | |||
9582b2223c | |||
d7908fb81f | |||
e48cdcb94f | |||
0846ad5fd0 | |||
84663ff2e2 | |||
6de1934420 | |||
a110b9fd27 | |||
eb06c122d1 | |||
cbbe851adb | |||
f6cc2e520f | |||
4e29b5aa29 | |||
d924f56ad8 | |||
f27fd095f7 |
@ -1,282 +0,0 @@
|
||||
#ifndef BOOST_ITERATOR_CONCEPTS_HPP
|
||||
#define BOOST_ITERATOR_CONCEPTS_HPP
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/iterator_traits.hpp>
|
||||
|
||||
namespace boost_concepts {
|
||||
// Used a different namespace here (instead of "boost") so that the
|
||||
// concept descriptions do not take for granted the names in
|
||||
// namespace boost.
|
||||
|
||||
|
||||
//===========================================================================
|
||||
|
||||
template <typename Iterator>
|
||||
class ReadableIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename boost::iterator_traits<Iterator>::reference reference;
|
||||
typedef typename boost::iterator_traits<Iterator>::return_category
|
||||
return_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
||||
boost::function_requires< boost::EqualityComparableConcept<Iterator> >();
|
||||
boost::function_requires< boost::DefaultConstructibleConcept<Iterator> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost::ConvertibleConcept<return_category, boost::readable_iterator_tag> >();
|
||||
|
||||
reference r = *i; // or perhaps read(x)
|
||||
value_type v(r);
|
||||
boost::ignore_unused_variable_warning(v);
|
||||
}
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator, typename ValueType>
|
||||
class WritableIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::return_category
|
||||
return_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
||||
boost::function_requires< boost::EqualityComparableConcept<Iterator> >();
|
||||
boost::function_requires< boost::DefaultConstructibleConcept<Iterator> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost::ConvertibleConcept<return_category, boost::writable_iterator_tag> >();
|
||||
|
||||
*i = v; // an alternative could be something like write(x, v)
|
||||
}
|
||||
ValueType v;
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class ConstantLvalueIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename boost::iterator_traits<Iterator>::reference reference;
|
||||
typedef typename boost::iterator_traits<Iterator>::return_category
|
||||
return_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost::ConvertibleConcept<return_category,
|
||||
boost::constant_lvalue_iterator_tag> >();
|
||||
|
||||
typedef typename boost::require_same<reference, const value_type&>::type req;
|
||||
|
||||
reference v = *i;
|
||||
boost::ignore_unused_variable_warning(v);
|
||||
}
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class MutableLvalueIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename boost::iterator_traits<Iterator>::reference reference;
|
||||
typedef typename boost::iterator_traits<Iterator>::return_category
|
||||
return_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
||||
boost::function_requires< WritableIteratorConcept<Iterator, value_type> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost::ConvertibleConcept<return_category,
|
||||
boost::constant_lvalue_iterator_tag> >();
|
||||
|
||||
typedef typename boost::require_same<reference, value_type&>::type req;
|
||||
|
||||
reference v = *i;
|
||||
boost::ignore_unused_variable_warning(v);
|
||||
}
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
|
||||
template <typename Iterator>
|
||||
class SinglePassIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::motion_category
|
||||
motion_category;
|
||||
typedef typename boost::iterator_traits<Iterator>::difference_type
|
||||
difference_type;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
||||
boost::function_requires< boost::EqualityComparableConcept<Iterator> >();
|
||||
boost::function_requires< boost::DefaultConstructibleConcept<Iterator> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost::ConvertibleConcept<motion_category,
|
||||
boost::single_pass_iterator_tag> >();
|
||||
|
||||
// difference_type must be a signed integral type
|
||||
|
||||
++i;
|
||||
(void)i++;
|
||||
}
|
||||
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class ForwardIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::motion_category
|
||||
motion_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< SinglePassIteratorConcept<Iterator> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost::ConvertibleConcept<motion_category,
|
||||
boost::forward_iterator_tag> >();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class BidirectionalIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::motion_category
|
||||
motion_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< ForwardIteratorConcept<Iterator> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost::ConvertibleConcept<motion_category,
|
||||
boost::bidirectional_iterator_tag> >();
|
||||
|
||||
--i;
|
||||
(void)i--;
|
||||
}
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class RandomAccessIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::motion_category
|
||||
motion_category;
|
||||
typedef typename boost::iterator_traits<Iterator>::difference_type
|
||||
difference_type;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< BidirectionalIteratorConcept<Iterator> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost::ConvertibleConcept<motion_category,
|
||||
boost::random_access_iterator_tag> >();
|
||||
|
||||
i += n;
|
||||
i = i + n;
|
||||
i = n + i;
|
||||
i -= n;
|
||||
i = i - n;
|
||||
n = i - j;
|
||||
}
|
||||
difference_type n;
|
||||
Iterator i, j;
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
|
||||
template <typename Iterator>
|
||||
class ReadableRandomAccessIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename boost::iterator_traits<Iterator>::reference reference;
|
||||
typedef typename boost::iterator_traits<Iterator>::difference_type
|
||||
difference_type;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< RandomAccessIteratorConcept<Iterator> >();
|
||||
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
||||
|
||||
reference r = i[n];
|
||||
value_type v(r);
|
||||
boost::ignore_unused_variable_warning(v);
|
||||
}
|
||||
difference_type n;
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class WritableRandomAccessIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename boost::iterator_traits<Iterator>::difference_type
|
||||
difference_type;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< RandomAccessIteratorConcept<Iterator> >();
|
||||
boost::function_requires< WritableIteratorConcept<Iterator, value_type> >();
|
||||
|
||||
i[n] = v;
|
||||
boost::ignore_unused_variable_warning(v);
|
||||
}
|
||||
difference_type n;
|
||||
value_type v;
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class ConstantLvalueRandomAccessIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename boost::iterator_traits<Iterator>::reference reference;
|
||||
typedef typename boost::iterator_traits<Iterator>::difference_type
|
||||
difference_type;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< RandomAccessIteratorConcept<Iterator> >();
|
||||
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
||||
|
||||
typedef typename boost::require_same<reference, const value_type&>::type req;
|
||||
|
||||
reference v = i[n];
|
||||
boost::ignore_unused_variable_warning(v);
|
||||
}
|
||||
difference_type n;
|
||||
value_type v;
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class MutableLvalueRandomAccessIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename boost::iterator_traits<Iterator>::reference reference;
|
||||
typedef typename boost::iterator_traits<Iterator>::difference_type
|
||||
difference_type;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< RandomAccessIteratorConcept<Iterator> >();
|
||||
boost::function_requires< WritableIteratorConcept<Iterator, value_type> >();
|
||||
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
||||
|
||||
typedef typename boost::require_same<reference, value_type&>::type req;
|
||||
|
||||
reference v = i[n];
|
||||
boost::ignore_unused_variable_warning(v);
|
||||
}
|
||||
difference_type n;
|
||||
value_type v;
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
} // namespace boost_concepts
|
||||
|
||||
|
||||
#endif // BOOST_ITERATOR_CONCEPTS_HPP
|
@ -1,60 +0,0 @@
|
||||
#ifndef BOOST_ITERATOR_TRAITS_HPP
|
||||
#define BOOST_ITERATOR_TRAITS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename Iterator>
|
||||
struct iterator_traits {
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef typename Iterator::reference reference;
|
||||
typedef typename Iterator::pointer pointer;
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
typedef typename Iterator::return_category return_category;
|
||||
typedef typename Iterator::motion_category motion_category;
|
||||
};
|
||||
|
||||
// Motion Categories
|
||||
struct single_pass_iterator_tag { };
|
||||
struct forward_iterator_tag : public single_pass_iterator_tag { };
|
||||
struct bidirectional_iterator_tag : public forward_iterator_tag { };
|
||||
struct random_access_iterator_tag : public bidirectional_iterator_tag { };
|
||||
|
||||
// Return Type Categories
|
||||
struct readable_iterator_tag { };
|
||||
struct writable_iterator_tag { };
|
||||
struct mutable_lvalue_iterator_tag : virtual public writable_iterator_tag,
|
||||
virtual public readable_iterator_tag { };
|
||||
struct constant_lvalue_iterator_tag : public readable_iterator_tag { };
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
namespace detail {
|
||||
template <bool IsConst>
|
||||
struct pointer_return_category {
|
||||
typedef constant_lvalue_iterator_tag type;
|
||||
};
|
||||
template <>
|
||||
struct pointer_return_category<false> {
|
||||
typedef mutable_lvalue_iterator_tag type;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
template <typename T>
|
||||
struct iterator_traits<T*> {
|
||||
typedef T value_type;
|
||||
typedef T& reference;
|
||||
typedef T* pointer;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef typename detail::pointer_return_category<is_const<T>::value>::type
|
||||
return_category;
|
||||
typedef random_access_iterator_tag motion_category;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ITERATOR_TRAITS_HPP
|
@ -1,13 +0,0 @@
|
||||
#include <boost/iterator_concepts.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
boost::function_requires<
|
||||
boost_concepts::MutableLvalueRandomAccessIteratorConcept<int*> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost_concepts::ConstantLvalueRandomAccessIteratorConcept<const int*> >();
|
||||
|
||||
return 0;
|
||||
}
|
55
include/boost/function_output_iterator.hpp
Normal file
55
include/boost/function_output_iterator.hpp
Normal file
@ -0,0 +1,55 @@
|
||||
// (C) Copyright Jeremy Siek 2001. Permission to copy, use, modify,
|
||||
// sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
|
||||
// Revision History:
|
||||
|
||||
// 27 Feb 2001 Jeremy Siek
|
||||
// Initial checkin.
|
||||
|
||||
#ifndef BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
|
||||
#define BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
|
||||
|
||||
#include <iterator>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <class UnaryFunction>
|
||||
class function_output_iterator {
|
||||
typedef function_output_iterator self;
|
||||
public:
|
||||
typedef std::output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
explicit function_output_iterator(const UnaryFunction& f = UnaryFunction())
|
||||
: m_f(f) {}
|
||||
|
||||
struct output_proxy {
|
||||
output_proxy(UnaryFunction& f) : m_f(f) { }
|
||||
template <class T> output_proxy& operator=(const T& value) {
|
||||
m_f(value);
|
||||
return *this;
|
||||
}
|
||||
UnaryFunction& m_f;
|
||||
};
|
||||
output_proxy operator*() { return output_proxy(m_f); }
|
||||
self& operator++() { return *this; }
|
||||
self& operator++(int) { return *this; }
|
||||
private:
|
||||
UnaryFunction m_f;
|
||||
};
|
||||
|
||||
template <class UnaryFunction>
|
||||
inline function_output_iterator<UnaryFunction>
|
||||
make_function_output_iterator(const UnaryFunction& f = UnaryFunction()) {
|
||||
return function_output_iterator<UnaryFunction>(f);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
|
@ -21,7 +21,7 @@
|
||||
|
||||
namespace boost
|
||||
{
|
||||
# ifdef BOOST_NO_STD_ITERATOR
|
||||
# if defined(BOOST_NO_STD_ITERATOR) && !defined(BOOST_MSVC_STD_ITERATOR)
|
||||
template <class Category, class T,
|
||||
class Distance = std::ptrdiff_t,
|
||||
class Pointer = T*, class Reference = T&>
|
||||
|
@ -12,6 +12,10 @@
|
||||
//
|
||||
// Revision History:
|
||||
|
||||
// 26 Sep 2001 David Abrahams
|
||||
// Added borland bug fix
|
||||
// 08 Mar 2001 Jeremy Siek
|
||||
// Added support for optional named template parameters.
|
||||
// 19 Feb 2001 David Abrahams
|
||||
// Rolled back reverse_iterator_pair_generator again, as it doesn't
|
||||
// save typing on a conforming compiler.
|
||||
@ -104,6 +108,7 @@
|
||||
# include <boost/type_traits.hpp>
|
||||
# include <boost/detail/iterator.hpp>
|
||||
# include <boost/detail/select_type.hpp>
|
||||
# include <boost/detail/named_template_params.hpp>
|
||||
|
||||
// I was having some problems with VC6. I couldn't tell whether our hack for
|
||||
// stock GCC was causing problems so I needed an easy way to turn it on and
|
||||
@ -220,6 +225,9 @@ struct default_iterator_policies
|
||||
void initialize(Base&)
|
||||
{ }
|
||||
|
||||
// The "type<Reference>" parameter is a portable mechanism for
|
||||
// the iterator_adaptor class to tell this member function what
|
||||
// the Reference type is, which is needed for the return type.
|
||||
template <class Reference, class Base>
|
||||
Reference dereference(type<Reference>, const Base& x) const
|
||||
{ return *x; }
|
||||
@ -429,8 +437,111 @@ namespace detail {
|
||||
|
||||
};
|
||||
# endif
|
||||
|
||||
//===========================================================================
|
||||
// Specify the defaults for iterator_adaptor's template parameters
|
||||
|
||||
struct default_value_type {
|
||||
template <class Base, class Traits>
|
||||
struct bind {
|
||||
typedef typename boost::detail::iterator_traits<Base>::value_type type;
|
||||
};
|
||||
};
|
||||
struct default_difference_type {
|
||||
template <class Base, class Traits>
|
||||
struct bind {
|
||||
typedef typename boost::detail::iterator_traits<Base>::difference_type type;
|
||||
};
|
||||
};
|
||||
struct default_iterator_category {
|
||||
template <class Base, class Traits>
|
||||
struct bind {
|
||||
typedef typename boost::detail::iterator_traits<Base>::iterator_category type;
|
||||
};
|
||||
};
|
||||
struct default_pointer {
|
||||
template <class Base, class Traits>
|
||||
struct bind {
|
||||
typedef typename Traits::value_type Value;
|
||||
typedef typename boost::detail::iterator_defaults<Base,Value>::pointer
|
||||
type;
|
||||
};
|
||||
};
|
||||
struct default_reference {
|
||||
template <class Base, class Traits>
|
||||
struct bind {
|
||||
typedef typename Traits::value_type Value;
|
||||
typedef typename boost::detail::iterator_defaults<Base,Value>::reference
|
||||
type;
|
||||
};
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
// Support for named template parameters
|
||||
|
||||
#if !defined(__BORLANDC__)
|
||||
// Borland C++ thinks the nested recursive inheritance here is illegal.
|
||||
|
||||
template <class V = default_argument,
|
||||
class R = default_argument,
|
||||
class P = default_argument,
|
||||
class C = default_argument,
|
||||
class D = default_argument>
|
||||
struct iter_traits_gen : public named_template_param_base {
|
||||
template <class T>
|
||||
struct value_type : public iter_traits_gen<T,R,P,C,D> { };
|
||||
template <class T>
|
||||
struct reference : public iter_traits_gen<V,T,P,C,D> { };
|
||||
template <class T>
|
||||
struct pointer : public iter_traits_gen<V,R,T,C,D> { };
|
||||
template <class T>
|
||||
struct iterator_category : public iter_traits_gen<V,R,P,T,D>{};
|
||||
template <class T>
|
||||
struct difference_type : public iter_traits_gen<V,R,P,C,T> { };
|
||||
|
||||
typedef boost::iterator<C, V, D, P, R> traits;
|
||||
};
|
||||
#endif
|
||||
|
||||
BOOST_NAMED_TEMPLATE_PARAM(value_type);
|
||||
BOOST_NAMED_TEMPLATE_PARAM(reference);
|
||||
BOOST_NAMED_TEMPLATE_PARAM(pointer);
|
||||
BOOST_NAMED_TEMPLATE_PARAM(iterator_category);
|
||||
BOOST_NAMED_TEMPLATE_PARAM(difference_type);
|
||||
|
||||
template <class Base, class Value, class Reference, class Pointer,
|
||||
class Category, class Distance>
|
||||
class iterator_adaptor_traits_gen
|
||||
{
|
||||
typedef boost::iterator<Category, Value, Distance, Pointer, Reference>
|
||||
Traits0;
|
||||
|
||||
typedef typename get_value_type<Base,
|
||||
typename boost::remove_const<Value>::type, Traits0
|
||||
>::type value_type;
|
||||
typedef typename get_difference_type<Base, Distance, Traits0>::type
|
||||
difference_type;
|
||||
typedef typename get_iterator_category<Base, Category, Traits0>::type
|
||||
iterator_category;
|
||||
|
||||
typedef boost::iterator<iterator_category, value_type, difference_type,
|
||||
Pointer, Reference> Traits1;
|
||||
|
||||
typedef typename get_pointer<Base, Pointer, Traits1>::type pointer;
|
||||
typedef typename get_reference<Base, Reference, Traits1>::type reference;
|
||||
public:
|
||||
typedef boost::iterator<iterator_category, value_type, difference_type,
|
||||
pointer, reference> type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
#if !defined(__BORLANDC__)
|
||||
struct iterator_traits_generator
|
||||
: public detail::iter_traits_gen<> { };
|
||||
#endif
|
||||
|
||||
// This macro definition is only temporary in this file
|
||||
# if !defined(BOOST_MSVC)
|
||||
# define BOOST_ARG_DEPENDENT_TYPENAME typename
|
||||
@ -469,29 +580,32 @@ template <class T> struct undefined;
|
||||
// Distance - the difference_type of the resulting iterator. If not
|
||||
// supplied, iterator_traits<Base>::difference_type is used.
|
||||
template <class Base, class Policies,
|
||||
class Value = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<Base>::value_type,
|
||||
class Reference = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_defaults<Base,Value>::reference,
|
||||
class Pointer = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_defaults<Base,Value>::pointer,
|
||||
class Category = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<Base>::iterator_category,
|
||||
class Distance = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<Base>::difference_type
|
||||
class Value = detail::default_argument,
|
||||
class Reference = BOOST_ARG_DEPENDENT_TYPENAME detail::choose_default_argument<Value>::type,
|
||||
class Pointer = BOOST_ARG_DEPENDENT_TYPENAME detail::choose_default_argument<Reference>::type,
|
||||
class Category = BOOST_ARG_DEPENDENT_TYPENAME detail::choose_default_argument<Pointer>::type,
|
||||
class Distance = BOOST_ARG_DEPENDENT_TYPENAME detail::choose_default_argument<Category>::type
|
||||
>
|
||||
struct iterator_adaptor :
|
||||
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
|
||||
iterator_comparisons<
|
||||
iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance>,
|
||||
#endif
|
||||
boost::iterator<Category,Value,Distance,Pointer,Reference>
|
||||
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
|
||||
>
|
||||
typename detail::iterator_adaptor_traits_gen<Base,Value,Reference,Pointer,Category, Distance>::type
|
||||
>
|
||||
#else
|
||||
detail::iterator_adaptor_traits_gen<Base,Value,Reference,Pointer,Category,Distance>::type
|
||||
#endif
|
||||
{
|
||||
typedef iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance> self;
|
||||
public:
|
||||
typedef Distance difference_type;
|
||||
typedef typename boost::remove_const<Value>::type value_type;
|
||||
typedef Pointer pointer;
|
||||
typedef Reference reference;
|
||||
typedef Category iterator_category;
|
||||
typedef typename detail::iterator_adaptor_traits_gen<Base,Value,Reference,Pointer,Category,Distance>::type Traits;
|
||||
|
||||
typedef typename Traits::difference_type difference_type;
|
||||
typedef typename Traits::value_type value_type;
|
||||
typedef typename Traits::pointer pointer;
|
||||
typedef typename Traits::reference reference;
|
||||
typedef typename Traits::iterator_category iterator_category;
|
||||
|
||||
typedef Base base_type;
|
||||
typedef Policies policies_type;
|
||||
|
||||
@ -503,14 +617,18 @@ struct iterator_adaptor :
|
||||
// Iterators should satisfy one of the known categories
|
||||
BOOST_STATIC_ASSERT(is_input_or_output_iter);
|
||||
|
||||
// Iterators >= ForwardIterator must produce real references.
|
||||
// Iterators >= ForwardIterator must produce real references
|
||||
// as required by the C++ standard requirements in Table 74.
|
||||
BOOST_STATIC_CONSTANT(bool, forward_iter_with_real_reference =
|
||||
(!boost::is_convertible<iterator_category*,std::forward_iterator_tag*>::value
|
||||
|| boost::is_same<reference,value_type&>::value
|
||||
|| boost::is_same<reference,const value_type&>::value));
|
||||
|
||||
#if !defined(BOOST_MSVC)
|
||||
// This check gives incorrect results in iter_traits_gen_test.cpp
|
||||
BOOST_STATIC_ASSERT(forward_iter_with_real_reference);
|
||||
|
||||
#endif
|
||||
|
||||
public:
|
||||
iterator_adaptor() { }
|
||||
|
||||
@ -528,9 +646,9 @@ struct iterator_adaptor :
|
||||
policies().initialize(iter());
|
||||
}
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#if defined(BOOST_MSVC) || defined(__BORLANDC__)
|
||||
// This is required to prevent a bug in how VC++ generates
|
||||
// the assignment operator for compressed_pair.
|
||||
// the assignment operator for compressed_pairv
|
||||
iterator_adaptor& operator= (const iterator_adaptor& x) {
|
||||
m_iter_p = x.m_iter_p;
|
||||
return *this;
|
||||
@ -540,16 +658,16 @@ struct iterator_adaptor :
|
||||
return policies().dereference(type<reference>(), iter());
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning( disable : 4284 )
|
||||
#endif
|
||||
|
||||
typename boost::detail::operator_arrow_result_generator<Category,value_type,Pointer>::type
|
||||
typename boost::detail::operator_arrow_result_generator<iterator_category,value_type,pointer>::type
|
||||
operator->() const
|
||||
{ return detail::operator_arrow(*this, Category()); }
|
||||
{ return detail::operator_arrow(*this, iterator_category()); }
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
@ -570,7 +688,11 @@ struct iterator_adaptor :
|
||||
self operator++(int) { self tmp(*this); ++*this; return tmp; }
|
||||
|
||||
self& operator--() {
|
||||
#ifdef __MWERKS__
|
||||
policies().decrement<Base>(iter());
|
||||
#else
|
||||
policies().decrement(iter());
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -590,7 +712,7 @@ struct iterator_adaptor :
|
||||
|
||||
// Moved from global scope to avoid ambiguity with the operator-() which
|
||||
// subtracts iterators from one another.
|
||||
self operator-(Distance x) const
|
||||
self operator-(difference_type x) const
|
||||
{ self result(*this); return result -= x; }
|
||||
private:
|
||||
compressed_pair<Base,Policies> m_iter_p;
|
||||
@ -626,11 +748,14 @@ operator+(
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2, class Category,
|
||||
class Distance>
|
||||
Distance operator-(
|
||||
typename iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>::difference_type
|
||||
operator-(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||
{
|
||||
return x.policies().distance(type<Distance>(), y.iter(), x.iter());
|
||||
typedef typename iterator_adaptor<Iterator1,Policies,Value1,Reference1,
|
||||
Pointer1,Category,Distance>::difference_type difference_type;
|
||||
return x.policies().distance(type<difference_type>(), y.iter(), x.iter());
|
||||
}
|
||||
|
||||
#ifndef BOOST_RELOPS_AMBIGUITY_BUG
|
||||
@ -967,14 +1092,19 @@ public:
|
||||
{ return x == y; }
|
||||
|
||||
private:
|
||||
void satisfy_predicate(Iterator& iter)
|
||||
{
|
||||
while (m_end != iter && !m_predicate(*iter))
|
||||
++iter;
|
||||
}
|
||||
void satisfy_predicate(Iterator& iter);
|
||||
Predicate m_predicate;
|
||||
Iterator m_end;
|
||||
};
|
||||
template <class Predicate, class Iterator>
|
||||
void filter_iterator_policies<Predicate,Iterator>
|
||||
::satisfy_predicate(Iterator& iter)
|
||||
{
|
||||
while (m_end != iter && !m_predicate(*iter))
|
||||
++iter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace detail {
|
||||
// A type generator returning Base if T is derived from Base, and T otherwise.
|
||||
@ -1005,6 +1135,7 @@ namespace detail {
|
||||
# else
|
||||
// is_convertible doesn't work with MWERKS
|
||||
typedef typename iterator_traits<Iterator>::iterator_category input_category;
|
||||
public:
|
||||
typedef typename if_true<(
|
||||
boost::is_same<input_category,std::random_access_iterator_tag>::value
|
||||
|| boost::is_same<input_category,std::bidirectional_iterator_tag>::value
|
||||
|
Reference in New Issue
Block a user