mirror of
https://github.com/boostorg/iterator.git
synced 2025-06-27 04:51:38 +02:00
Compare commits
8 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
b5d52c52d9 | |||
92d461cda1 | |||
8dace06f04 | |||
ef0bff57d3 | |||
5bacd289b6 | |||
77c1698c6e | |||
2c302ee549 | |||
a586f20d19 |
@ -4,7 +4,7 @@
|
||||
// without express or implied warranty, and with no claim as to its suitability
|
||||
// for any purpose.
|
||||
//
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
// See http://www.boost.org/libs/utility/counting_iterator.htm for documentation.
|
||||
//
|
||||
// Supplies:
|
||||
//
|
||||
|
@ -5,7 +5,7 @@
|
||||
// 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.
|
||||
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
// See http://www.boost.org/libs/utility for documentation.
|
||||
|
||||
// Revision History
|
||||
// 12 Jan 01 added <cstddef> for std::ptrdiff_t (Jens Maurer)
|
||||
|
@ -9,7 +9,9 @@
|
||||
// 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.
|
||||
//
|
||||
|
||||
// See http://www.boost.org/libs/utility/iterator_adaptors.htm for documentation.
|
||||
|
||||
// Revision History:
|
||||
|
||||
// 01 Feb 2002 Jeremy Siek
|
||||
@ -121,17 +123,14 @@
|
||||
# include <boost/utility.hpp>
|
||||
# include <boost/compressed_pair.hpp>
|
||||
# include <boost/concept_check.hpp>
|
||||
# include <boost/type.hpp>
|
||||
# include <boost/static_assert.hpp>
|
||||
# include <boost/type_traits.hpp>
|
||||
# include <boost/type_traits/conversion_traits.hpp>
|
||||
# include <boost/detail/iterator.hpp>
|
||||
# include <boost/detail/select_type.hpp>
|
||||
# include <boost/detail/workaround.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
|
||||
// off. Now we can test the hack with various compilers and still have an
|
||||
// "out" if it doesn't work. -dwa 7/31/00
|
||||
# if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 && !defined(__STL_USE_NAMESPACES)
|
||||
# if BOOST_WORKAROUND(__GNUC__, == 2) && __GNUC_MINOR__ <= 96 && !defined(__STL_USE_NAMESPACES)
|
||||
# define BOOST_RELOPS_AMBIGUITY_BUG 1
|
||||
# endif
|
||||
|
||||
@ -565,7 +564,7 @@ namespace detail {
|
||||
// An associative list is a list of key-value pairs. The list is
|
||||
// built out of cons_type's and is terminated by end_of_list.
|
||||
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(__BORLANDC__)
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || BOOST_WORKAROUND(__BORLANDC__, != 0)
|
||||
template <class AssocList, class Key>
|
||||
struct find_param;
|
||||
|
||||
@ -628,7 +627,7 @@ namespace detail {
|
||||
enum { value = is_convertible< typename add_reference< Value >::type, add_reference< named_template_param_base >::type >::value };
|
||||
};
|
||||
|
||||
# if defined(__MWERKS__) && __MWERKS__ <= 0x2406 // workaround for broken is_convertible implementation
|
||||
# if BOOST_WORKAROUND(__MWERKS__, <= 0x2407) // workaround for broken is_convertible implementation
|
||||
template <class T> struct is_named_parameter<value_type_is<T> > { enum { value = true }; };
|
||||
template <class T> struct is_named_parameter<reference_is<T> > { enum { value = true }; };
|
||||
template <class T> struct is_named_parameter<pointer_is<T> > { enum { value = true }; };
|
||||
@ -638,7 +637,7 @@ namespace detail {
|
||||
|
||||
template <class Key, class Value>
|
||||
struct make_arg {
|
||||
# ifdef __BORLANDC__
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, > 0)
|
||||
// Borland C++ doesn't like the extra indirection of is_named_parameter
|
||||
typedef typename
|
||||
if_true<(is_convertible<Value,named_template_param_base>::value)>::
|
||||
@ -761,12 +760,18 @@ namespace detail {
|
||||
|
||||
BOOST_STATIC_ASSERT(forward_iter_with_real_reference);
|
||||
};
|
||||
|
||||
template <class T, class Result> struct dependent
|
||||
{
|
||||
typedef Result type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
|
||||
// This macro definition is only temporary in this file
|
||||
# if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
# define BOOST_ARG_DEPENDENT_TYPENAME typename
|
||||
# else
|
||||
# define BOOST_ARG_DEPENDENT_TYPENAME
|
||||
@ -855,7 +860,7 @@ struct iterator_adaptor :
|
||||
policies().initialize(base());
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 || defined(__BORLANDC__)
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) || BOOST_WORKAROUND(__BORLANDC__, > 0)
|
||||
// This is required to prevent a bug in how VC++ generates
|
||||
// the assignment operator for compressed_pair
|
||||
iterator_adaptor& operator= (const iterator_adaptor& x) {
|
||||
@ -867,7 +872,7 @@ struct iterator_adaptor :
|
||||
return policies().dereference(*this);
|
||||
}
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, > 0)
|
||||
# pragma warning(push)
|
||||
# pragma warning( disable : 4284 )
|
||||
#endif
|
||||
@ -876,15 +881,16 @@ struct iterator_adaptor :
|
||||
operator->() const
|
||||
{ return detail::operator_arrow(*this, iterator_category()); }
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, > 0)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
value_type operator[](difference_type n) const
|
||||
template <class diff_type>
|
||||
typename detail::dependent<diff_type, value_type>::type operator[](diff_type n) const
|
||||
{ return *(*this + n); }
|
||||
|
||||
self& operator++() {
|
||||
#if !defined(__MWERKS__) || __MWERKS__ >= 0x2405
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, < 0x2405)
|
||||
policies().increment(*this);
|
||||
#else
|
||||
// Odd bug, MWERKS couldn't deduce the type for the member template
|
||||
@ -897,7 +903,7 @@ struct iterator_adaptor :
|
||||
self operator++(int) { self tmp(*this); ++*this; return tmp; }
|
||||
|
||||
self& operator--() {
|
||||
#if !defined(__MWERKS__) || __MWERKS__ >= 0x2405
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, < 0x2405)
|
||||
policies().decrement(*this);
|
||||
#else
|
||||
policies().decrement<self>(*this);
|
||||
@ -1097,7 +1103,7 @@ struct indirect_iterator_policies : public default_iterator_policies
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
# if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 // strangely instantiated even when unused! Maybe try a recursive template someday ;-)
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // strangely instantiated even when unused! Maybe try a recursive template someday ;-)
|
||||
template <class T>
|
||||
struct traits_of_value_type {
|
||||
typedef typename boost::detail::iterator_traits<T>::value_type outer_value;
|
||||
@ -1110,12 +1116,12 @@ namespace detail {
|
||||
|
||||
template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||
class Value
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::value_type
|
||||
#endif
|
||||
, class Reference
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::reference
|
||||
#else
|
||||
@ -1124,7 +1130,7 @@ template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||
, class Category = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<
|
||||
OuterIterator>::iterator_category
|
||||
, class Pointer
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::pointer
|
||||
#else
|
||||
@ -1139,12 +1145,12 @@ struct indirect_iterator_generator
|
||||
|
||||
template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||
class Value
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::value_type
|
||||
#endif
|
||||
, class Reference
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::reference
|
||||
#else
|
||||
@ -1154,7 +1160,7 @@ template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||
, class Category = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<
|
||||
OuterIterator>::iterator_category
|
||||
, class Pointer
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::pointer
|
||||
#else
|
||||
@ -1170,7 +1176,7 @@ struct indirect_iterator_pair_generator
|
||||
Value, ConstReference,Category,ConstPointer>::type const_iterator;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
template <class OuterIterator>
|
||||
inline typename indirect_iterator_generator<OuterIterator>::type
|
||||
make_indirect_iterator(OuterIterator base)
|
||||
@ -1356,7 +1362,7 @@ namespace detail {
|
||||
template <class Iterator>
|
||||
struct non_bidirectional_category
|
||||
{
|
||||
# if !defined(__MWERKS__) || __MWERKS__ > 0x2406
|
||||
# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
typedef typename reduce_to_base_class<
|
||||
std::forward_iterator_tag,
|
||||
typename iterator_traits<Iterator>::iterator_category
|
||||
@ -1392,7 +1398,7 @@ template <class Predicate, class Iterator,
|
||||
class filter_iterator_generator {
|
||||
BOOST_STATIC_CONSTANT(bool, is_bidirectional
|
||||
= (boost::is_convertible<Category*, std::bidirectional_iterator_tag*>::value));
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 // I don't have any idea why this occurs, but it doesn't seem to hurt too badly.
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // I don't have any idea why this occurs, but it doesn't seem to hurt too badly.
|
||||
BOOST_STATIC_ASSERT(!is_bidirectional);
|
||||
#endif
|
||||
typedef filter_iterator_policies<Predicate,Iterator> policies_type;
|
||||
|
@ -1,75 +0,0 @@
|
||||
// (C) Copyright Jeremy Siek 1999. 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.
|
||||
|
||||
#ifndef BOOST_INT_ITERATOR_H
|
||||
#define BOOST_INT_ITERATOR_H
|
||||
|
||||
#include <boost/iterator.hpp>
|
||||
#if !defined BOOST_MSVC
|
||||
#include <boost/operators.hpp>
|
||||
#endif
|
||||
#include <iostream>
|
||||
//using namespace std;
|
||||
|
||||
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
|
||||
namespace boost {
|
||||
#endif
|
||||
|
||||
// this should use random_access_iterator_helper but I've had
|
||||
// VC++ portablility problems with that. -JGS
|
||||
template <class IntT>
|
||||
class int_iterator
|
||||
{
|
||||
typedef int_iterator self;
|
||||
public:
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
typedef IntT value_type;
|
||||
typedef IntT& reference;
|
||||
typedef IntT* pointer;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
inline int_iterator() : _i(0) { }
|
||||
inline int_iterator(IntT i) : _i(i) { }
|
||||
inline int_iterator(const self& x) : _i(x._i) { }
|
||||
inline self& operator=(const self& x) { _i = x._i; return *this; }
|
||||
inline IntT operator*() { return _i; }
|
||||
inline IntT operator[](IntT n) { return _i + n; }
|
||||
inline self& operator++() { ++_i; return *this; }
|
||||
inline self operator++(int) { self t = *this; ++_i; return t; }
|
||||
inline self& operator+=(IntT n) { _i += n; return *this; }
|
||||
inline self operator+(IntT n) { self t = *this; t += n; return t; }
|
||||
inline self& operator--() { --_i; return *this; }
|
||||
inline self operator--(int) { self t = *this; --_i; return t; }
|
||||
inline self& operator-=(IntT n) { _i -= n; return *this; }
|
||||
inline IntT operator-(const self& x) const { return _i - x._i; }
|
||||
inline bool operator==(const self& x) const { return _i == x._i; }
|
||||
// vc++ had a problem finding != in random_access_iterator_helper
|
||||
// need to look into this... for now implementing everything here -JGS
|
||||
inline bool operator!=(const self& x) const { return _i != x._i; }
|
||||
inline bool operator<(const self& x) const { return _i < x._i; }
|
||||
inline bool operator<=(const self& x) const { return _i <= x._i; }
|
||||
inline bool operator>(const self& x) const { return _i > x._i; }
|
||||
inline bool operator>=(const self& x) const { return _i >= x._i; }
|
||||
protected:
|
||||
IntT _i;
|
||||
};
|
||||
|
||||
template <class IntT>
|
||||
inline int_iterator<IntT>
|
||||
operator+(IntT n, int_iterator<IntT> t) { t += n; return t; }
|
||||
|
||||
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
|
||||
} /* namespace boost */
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_OPERATORS_IN_NAMESPACE
|
||||
namespace boost {
|
||||
using ::int_iterator;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* BOOST_INT_ITERATOR_H */
|
@ -1,59 +0,0 @@
|
||||
// (C) Copyright David Abrahams and Jeremy Siek 2000-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:
|
||||
// 04 Jan 2001 Factored counting_iterator stuff into
|
||||
// boost/counting_iterator.hpp (David Abrahams)
|
||||
|
||||
#ifndef BOOST_INTEGER_RANGE_HPP_
|
||||
#define BOOST_INTEGER_RANGE_HPP_
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/counting_iterator.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//=============================================================================
|
||||
// Counting Iterator and Integer Range Class
|
||||
|
||||
template <class IntegerType>
|
||||
struct integer_range {
|
||||
typedef typename counting_iterator_generator<IntegerType>::type iterator;
|
||||
|
||||
typedef iterator const_iterator;
|
||||
typedef IntegerType value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef IntegerType reference;
|
||||
typedef IntegerType const_reference;
|
||||
typedef const IntegerType* pointer;
|
||||
typedef const IntegerType* const_pointer;
|
||||
typedef IntegerType size_type;
|
||||
|
||||
integer_range(IntegerType start, IntegerType finish)
|
||||
: m_start(start), m_finish(finish) { }
|
||||
|
||||
iterator begin() const { return iterator(m_start); }
|
||||
iterator end() const { return iterator(m_finish); }
|
||||
size_type size() const { return m_finish - m_start; }
|
||||
bool empty() const { return m_finish == m_start; }
|
||||
void swap(integer_range& x) {
|
||||
std::swap(m_start, x.m_start);
|
||||
std::swap(m_finish, x.m_finish);
|
||||
}
|
||||
protected:
|
||||
IntegerType m_start, m_finish;
|
||||
};
|
||||
|
||||
template <class IntegerType>
|
||||
inline integer_range<IntegerType>
|
||||
make_integer_range(IntegerType first, IntegerType last)
|
||||
{
|
||||
return integer_range<IntegerType>(first, last);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_INTEGER_RANGE_HPP_
|
@ -1 +0,0 @@
|
||||
#include <boost/iterator_adaptors.hpp>
|
@ -1,253 +0,0 @@
|
||||
#ifndef BOOST_ITERATOR_TESTS_HPP
|
||||
# define BOOST_ITERATOR_TESTS_HPP
|
||||
|
||||
// This is meant to be the beginnings of a comprehensive, generic
|
||||
// test suite for STL concepts such as iterators and containers.
|
||||
//
|
||||
// Revision History:
|
||||
// 28 Apr 2002 Fixed input iterator requirements.
|
||||
// For a == b a++ == b++ is no longer required.
|
||||
// See 24.1.1/3 for details.
|
||||
// (Thomas Witt)
|
||||
// 08 Feb 2001 Fixed bidirectional iterator test so that
|
||||
// --i is no longer a precondition.
|
||||
// (Jeremy Siek)
|
||||
// 04 Feb 2001 Added lvalue test, corrected preconditions
|
||||
// (David Abrahams)
|
||||
|
||||
# include <iterator>
|
||||
# include <assert.h>
|
||||
# include <boost/type_traits.hpp>
|
||||
# include <boost/static_assert.hpp>
|
||||
# include <boost/concept_archetype.hpp> // for detail::dummy_constructor
|
||||
|
||||
namespace boost {
|
||||
|
||||
// use this for the value type
|
||||
struct dummyT {
|
||||
dummyT() { }
|
||||
dummyT(detail::dummy_constructor) { }
|
||||
dummyT(int x) : m_x(x) { }
|
||||
int foo() const { return m_x; }
|
||||
bool operator==(const dummyT& d) const { return m_x == d.m_x; }
|
||||
int m_x;
|
||||
};
|
||||
|
||||
|
||||
// Tests whether type Iterator satisfies the requirements for a
|
||||
// TrivialIterator.
|
||||
// Preconditions: i != j, *i == val
|
||||
template <class Iterator, class T>
|
||||
void trivial_iterator_test(const Iterator i, const Iterator j, T val)
|
||||
{
|
||||
Iterator k;
|
||||
assert(i == i);
|
||||
assert(j == j);
|
||||
assert(i != j);
|
||||
#ifdef BOOST_NO_STD_ITERATOR_TRAITS
|
||||
T v = *i;
|
||||
#else
|
||||
typename std::iterator_traits<Iterator>::value_type v = *i;
|
||||
#endif
|
||||
assert(v == val);
|
||||
#if 0
|
||||
// hmm, this will give a warning for transform_iterator... perhaps
|
||||
// this should be separated out into a stand-alone test since there
|
||||
// are several situations where it can't be used, like for
|
||||
// integer_range::iterator.
|
||||
assert(v == i->foo());
|
||||
#endif
|
||||
k = i;
|
||||
assert(k == k);
|
||||
assert(k == i);
|
||||
assert(k != j);
|
||||
assert(*k == val);
|
||||
}
|
||||
|
||||
|
||||
// Preconditions: i != j
|
||||
template <class Iterator, class T>
|
||||
void mutable_trivial_iterator_test(const Iterator i, const Iterator j, T val)
|
||||
{
|
||||
*i = val;
|
||||
trivial_iterator_test(i, j, val);
|
||||
}
|
||||
|
||||
|
||||
// Preconditions: *i == v1, *++i == v2
|
||||
template <class Iterator, class T>
|
||||
void input_iterator_test(Iterator i, T v1, T v2)
|
||||
{
|
||||
Iterator i1(i);
|
||||
|
||||
assert(i == i1);
|
||||
assert(!(i != i1));
|
||||
|
||||
// I can see no generic way to create an input iterator
|
||||
// that is in the domain of== of i and != i.
|
||||
// The following works for istream_iterator but is not
|
||||
// guaranteed to work for arbitrary input iterators.
|
||||
//
|
||||
// Iterator i2;
|
||||
//
|
||||
// assert(i != i2);
|
||||
// assert(!(i == i2));
|
||||
|
||||
assert(*i1 == v1);
|
||||
assert(*i == v1);
|
||||
|
||||
// we cannot test for equivalence of (void)++i & (void)i++
|
||||
// as i is only guaranteed to be single pass.
|
||||
assert(*i++ == v1);
|
||||
|
||||
i1 = i;
|
||||
|
||||
assert(i == i1);
|
||||
assert(!(i != i1));
|
||||
|
||||
assert(*i1 == v2);
|
||||
assert(*i == v2);
|
||||
|
||||
// i is dereferencable, so it must be incrementable.
|
||||
++i;
|
||||
|
||||
// how to test for operator-> ?
|
||||
}
|
||||
|
||||
// how to test output iterator?
|
||||
|
||||
|
||||
template <bool is_pointer> struct lvalue_test
|
||||
{
|
||||
template <class Iterator> static void check(Iterator)
|
||||
{
|
||||
# ifndef BOOST_NO_STD_ITERATOR_TRAITS
|
||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||
# else
|
||||
typedef typename Iterator::reference reference;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
# endif
|
||||
BOOST_STATIC_ASSERT(boost::is_reference<reference>::value);
|
||||
BOOST_STATIC_ASSERT((boost::is_same<reference,value_type&>::value
|
||||
|| boost::is_same<reference,const value_type&>::value
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
# ifdef BOOST_NO_STD_ITERATOR_TRAITS
|
||||
template <> struct lvalue_test<true> {
|
||||
template <class T> static void check(T) {}
|
||||
};
|
||||
#endif
|
||||
|
||||
template <class Iterator, class T>
|
||||
void forward_iterator_test(Iterator i, T v1, T v2)
|
||||
{
|
||||
input_iterator_test(i, v1, v2);
|
||||
|
||||
Iterator i1 = i, i2 = i;
|
||||
|
||||
assert(i == i1++);
|
||||
assert(i != ++i2);
|
||||
|
||||
trivial_iterator_test(i, i1, v1);
|
||||
trivial_iterator_test(i, i2, v1);
|
||||
|
||||
++i;
|
||||
assert(i == i1);
|
||||
assert(i == i2);
|
||||
++i1;
|
||||
++i2;
|
||||
|
||||
trivial_iterator_test(i, i1, v2);
|
||||
trivial_iterator_test(i, i2, v2);
|
||||
|
||||
// borland doesn't allow non-type template parameters
|
||||
# if !defined(__BORLANDC__) || (__BORLANDC__ > 0x551)
|
||||
lvalue_test<(boost::is_pointer<Iterator>::value)>::check(i);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Preconditions: *i == v1, *++i == v2
|
||||
template <class Iterator, class T>
|
||||
void bidirectional_iterator_test(Iterator i, T v1, T v2)
|
||||
{
|
||||
forward_iterator_test(i, v1, v2);
|
||||
++i;
|
||||
|
||||
Iterator i1 = i, i2 = i;
|
||||
|
||||
assert(i == i1--);
|
||||
assert(i != --i2);
|
||||
|
||||
trivial_iterator_test(i, i1, v2);
|
||||
trivial_iterator_test(i, i2, v2);
|
||||
|
||||
--i;
|
||||
assert(i == i1);
|
||||
assert(i == i2);
|
||||
++i1;
|
||||
++i2;
|
||||
|
||||
trivial_iterator_test(i, i1, v1);
|
||||
trivial_iterator_test(i, i2, v1);
|
||||
}
|
||||
|
||||
// mutable_bidirectional_iterator_test
|
||||
|
||||
// Preconditions: [i,i+N) is a valid range
|
||||
template <class Iterator, class TrueVals>
|
||||
void random_access_iterator_test(Iterator i, int N, TrueVals vals)
|
||||
{
|
||||
bidirectional_iterator_test(i, vals[0], vals[1]);
|
||||
const Iterator j = i;
|
||||
int c;
|
||||
|
||||
for (c = 0; c < N-1; ++c) {
|
||||
assert(i == j + c);
|
||||
assert(*i == vals[c]);
|
||||
assert(*i == j[c]);
|
||||
assert(*i == *(j + c));
|
||||
assert(*i == *(c + j));
|
||||
++i;
|
||||
assert(i > j);
|
||||
assert(i >= j);
|
||||
assert(j <= i);
|
||||
assert(j < i);
|
||||
}
|
||||
|
||||
Iterator k = j + N - 1;
|
||||
for (c = 0; c < N-1; ++c) {
|
||||
assert(i == k - c);
|
||||
assert(*i == vals[N - 1 - c]);
|
||||
assert(*i == j[N - 1 - c]);
|
||||
Iterator q = k - c;
|
||||
assert(*i == *q);
|
||||
assert(i > j);
|
||||
assert(i >= j);
|
||||
assert(j <= i);
|
||||
assert(j < i);
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
// Precondition: i != j
|
||||
template <class Iterator, class ConstIterator>
|
||||
void const_nonconst_iterator_test(Iterator i, ConstIterator j)
|
||||
{
|
||||
assert(i != j);
|
||||
assert(j != i);
|
||||
|
||||
ConstIterator k(i);
|
||||
assert(k == i);
|
||||
assert(i == k);
|
||||
|
||||
k = i;
|
||||
assert(k == i);
|
||||
assert(i == k);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ITERATOR_TESTS_HPP
|
@ -5,6 +5,8 @@
|
||||
// to its suitability for any purpose.
|
||||
//
|
||||
|
||||
// See http://www.boost.org/libs/utility/permutation_iterator.htm for documentation.
|
||||
|
||||
#ifndef boost_permutation_iterator_hpp
|
||||
#define boost_permutation_iterator_hpp
|
||||
|
||||
|
59
include/boost/shared_container_iterator.hpp
Normal file
59
include/boost/shared_container_iterator.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
// (C) Copyright Ronald Garcia 2002. 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.
|
||||
|
||||
// See http://www.boost.org/libs/utility/shared_container_iterator.html for documentation.
|
||||
|
||||
#ifndef SHARED_CONTAINER_ITERATOR_RG08102002_HPP
|
||||
#define SHARED_CONTAINER_ITERATOR_RG08102002_HPP
|
||||
|
||||
#include "boost/iterator_adaptors.hpp"
|
||||
#include "boost/shared_ptr.hpp"
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename Container>
|
||||
struct shared_container_iterator_policies :
|
||||
public boost::default_iterator_policies {
|
||||
typedef boost::shared_ptr<Container> container_ref_t;
|
||||
container_ref_t container_ref;
|
||||
shared_container_iterator_policies(container_ref_t const& c) :
|
||||
container_ref(c) { }
|
||||
shared_container_iterator_policies() { }
|
||||
};
|
||||
|
||||
|
||||
template <typename Container>
|
||||
class shared_container_iterator_generator {
|
||||
typedef typename Container::iterator iterator;
|
||||
typedef shared_container_iterator_policies<Container> policy;
|
||||
public:
|
||||
typedef boost::iterator_adaptor<iterator,policy> type;
|
||||
};
|
||||
|
||||
template <typename Container>
|
||||
typename shared_container_iterator_generator<Container>::type
|
||||
make_shared_container_iterator(typename Container::iterator iter,
|
||||
boost::shared_ptr<Container> const& container) {
|
||||
typedef typename shared_container_iterator_generator<Container>::type
|
||||
iterator;
|
||||
typedef shared_container_iterator_policies<Container> policy;
|
||||
return iterator(iter,policy(container));
|
||||
}
|
||||
|
||||
template <typename Container>
|
||||
std::pair<
|
||||
typename shared_container_iterator_generator<Container>::type,
|
||||
typename shared_container_iterator_generator<Container>::type>
|
||||
make_shared_container_range(boost::shared_ptr<Container> const& container) {
|
||||
return
|
||||
std::make_pair(
|
||||
make_shared_container_iterator(container->begin(),container),
|
||||
make_shared_container_iterator(container->end(),container));
|
||||
}
|
||||
|
||||
|
||||
} // namespace boost
|
||||
#endif // SHARED_CONTAINER_ITERATOR_RG08102002_HPP
|
Reference in New Issue
Block a user