mirror of
https://github.com/boostorg/iterator.git
synced 2026-01-20 16:42:16 +00:00
Compare commits
1 Commits
boost-1.30
...
boost-1.26
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d612a730d |
226
include/boost/counting_iterator.hpp
Normal file
226
include/boost/counting_iterator.hpp
Normal file
@@ -0,0 +1,226 @@
|
||||
// (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.
|
||||
//
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
//
|
||||
// Supplies:
|
||||
//
|
||||
// template <class Incrementable> class counting_iterator_traits;
|
||||
// template <class Incrementable> class counting_iterator_policies;
|
||||
//
|
||||
// Iterator traits and policies for adapted iterators whose dereferenced
|
||||
// value progresses through consecutive values of Incrementable when the
|
||||
// iterator is derferenced.
|
||||
//
|
||||
// template <class Incrementable> struct counting_iterator_generator;
|
||||
//
|
||||
// A "type generator" whose nested type "type" is a counting iterator as
|
||||
// described above.
|
||||
//
|
||||
// template <class Incrementable>
|
||||
// typename counting_iterator_generator<Incrementable>::type
|
||||
// make_counting_iterator(Incrementable);
|
||||
//
|
||||
// A function which produces an adapted counting iterator over values of
|
||||
// Incrementable.
|
||||
//
|
||||
// Revision History
|
||||
// 14 Feb 2001 Removed unnecessary typedefs from counting_iterator_traits
|
||||
// (Jeremy Siek)
|
||||
// 11 Feb 2001 Use BOOST_STATIC_CONSTANT (Dave Abrahams)
|
||||
// 11 Feb 2001 Clean up after John Maddocks's (finally effective!) Borland
|
||||
// fixes (David Abrahams).
|
||||
// 10 Feb 2001 Use new iterator_adaptor<> interface (David Abrahams)
|
||||
// 10 Feb 2001 Rolled in supposed Borland fixes from John Maddock, but not
|
||||
// seeing any improvement yet (David Abrahams)
|
||||
// 09 Feb 2001 Factored out is_numeric computation. Borland still
|
||||
// unhappy :( (David Abrahams)
|
||||
// 08 Feb 2001 Beginning of a failed attempt to appease Borland
|
||||
// (David Abrahams)
|
||||
// 07 Feb 2001 rename counting_iterator() -> make_counting_iterator()
|
||||
// (David Abrahams)
|
||||
// 04 Feb 2001 Added counting_iterator_generator; updated comments
|
||||
// (David Abrahams)
|
||||
// 24 Jan 2001 initial revision, based on Jeremy Siek's
|
||||
// boost/pending/integer_range.hpp (David Abrahams)
|
||||
|
||||
#ifndef BOOST_COUNTING_ITERATOR_HPP_DWA20000119
|
||||
# define BOOST_COUNTING_ITERATOR_HPP_DWA20000119
|
||||
|
||||
# include <boost/config.hpp>
|
||||
# include <boost/detail/iterator.hpp>
|
||||
# include <boost/iterator_adaptors.hpp>
|
||||
# include <boost/type_traits.hpp>
|
||||
# include <boost/detail/numeric_traits.hpp>
|
||||
# include <boost/static_assert.hpp>
|
||||
# ifndef BOOST_NO_LIMITS
|
||||
# include <limits>
|
||||
# endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Template class counting_iterator_traits_select -- choose an
|
||||
// iterator_category and difference_type for a counting_iterator at
|
||||
// compile-time based on whether or not it wraps an integer or an iterator,
|
||||
// using "poor man's partial specialization".
|
||||
template <bool is_integer> struct counting_iterator_traits_select;
|
||||
|
||||
// Incrementable is an iterator type
|
||||
template <>
|
||||
struct counting_iterator_traits_select<false>
|
||||
{
|
||||
template <class Incrementable>
|
||||
struct traits
|
||||
{
|
||||
private:
|
||||
typedef boost::detail::iterator_traits<Incrementable> x;
|
||||
public:
|
||||
typedef typename x::iterator_category iterator_category;
|
||||
typedef typename x::difference_type difference_type;
|
||||
};
|
||||
};
|
||||
|
||||
// Incrementable is a numeric type
|
||||
template <>
|
||||
struct counting_iterator_traits_select<true>
|
||||
{
|
||||
template <class Incrementable>
|
||||
struct traits
|
||||
{
|
||||
typedef typename
|
||||
boost::detail::numeric_traits<Incrementable>::difference_type
|
||||
difference_type;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
};
|
||||
};
|
||||
|
||||
// Template class distance_policy_select -- choose a policy for computing the
|
||||
// distance between counting_iterators at compile-time based on whether or not
|
||||
// the iterator wraps an integer or an iterator, using "poor man's partial
|
||||
// specialization".
|
||||
|
||||
template <bool is_integer> struct distance_policy_select;
|
||||
|
||||
// A policy for wrapped iterators
|
||||
template <>
|
||||
struct distance_policy_select<false>
|
||||
{
|
||||
template <class Distance, class Incrementable>
|
||||
struct policy {
|
||||
static Distance distance(Incrementable x, Incrementable y)
|
||||
{ return boost::detail::distance(x, y); }
|
||||
};
|
||||
};
|
||||
|
||||
// A policy for wrapped numbers
|
||||
template <>
|
||||
struct distance_policy_select<true>
|
||||
{
|
||||
template <class Distance, class Incrementable>
|
||||
struct policy {
|
||||
static Distance distance(Incrementable x, Incrementable y)
|
||||
{ return numeric_distance(x, y); }
|
||||
};
|
||||
};
|
||||
|
||||
// Try to detect numeric types at compile time in ways compatible with the
|
||||
// limitations of the compiler and library.
|
||||
template <class T>
|
||||
struct is_numeric {
|
||||
// For a while, this wasn't true, but we rely on it below. This is a regression assert.
|
||||
BOOST_STATIC_ASSERT(::boost::is_integral<char>::value);
|
||||
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
# if defined(ULLONG_MAX) || defined(ULONG_LONG_MAX)
|
||||
BOOST_STATIC_CONSTANT(bool,
|
||||
value = (
|
||||
std::numeric_limits<T>::is_specialized
|
||||
| boost::is_same<T,long long>::value
|
||||
| boost::is_same<T,unsigned long long>::value));
|
||||
# else
|
||||
BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits<T>::is_specialized);
|
||||
# endif
|
||||
# else
|
||||
# if !defined(__BORLANDC__)
|
||||
BOOST_STATIC_CONSTANT(bool, value = (
|
||||
boost::is_convertible<int,T>::value && boost::is_convertible<T,int>::value));
|
||||
# else
|
||||
BOOST_STATIC_CONSTANT(bool, value = ::boost::is_arithmetic<T>::value);
|
||||
# endif
|
||||
# endif
|
||||
};
|
||||
|
||||
// Compute the distance over arbitrary numeric and/or iterator types
|
||||
template <class Distance, class Incrementable>
|
||||
Distance any_distance(Incrementable start, Incrementable finish, Distance* = 0)
|
||||
{
|
||||
|
||||
return distance_policy_select<(
|
||||
is_numeric<Incrementable>::value)>::template
|
||||
policy<Distance, Incrementable>::distance(start, finish);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class Incrementable>
|
||||
struct counting_iterator_traits {
|
||||
private:
|
||||
typedef ::boost::detail::counting_iterator_traits_select<(
|
||||
::boost::detail::is_numeric<Incrementable>::value
|
||||
)> binder;
|
||||
typedef typename binder::template traits<Incrementable> traits;
|
||||
public:
|
||||
typedef typename traits::difference_type difference_type;
|
||||
typedef typename traits::iterator_category iterator_category;
|
||||
};
|
||||
|
||||
template <class Incrementable>
|
||||
struct counting_iterator_policies : public default_iterator_policies
|
||||
{
|
||||
template <class IteratorAdaptor>
|
||||
typename IteratorAdaptor::reference dereference(const IteratorAdaptor& i) const
|
||||
{ return i.base(); }
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
typename Iterator1::difference_type distance(
|
||||
const Iterator1& x, const Iterator2& y) const
|
||||
{
|
||||
typedef typename Iterator1::difference_type difference_type;
|
||||
return boost::detail::any_distance<difference_type>(
|
||||
x.base(), y.base());
|
||||
}
|
||||
};
|
||||
|
||||
// A type generator for counting iterators
|
||||
template <class Incrementable>
|
||||
struct counting_iterator_generator
|
||||
{
|
||||
typedef counting_iterator_traits<Incrementable> traits;
|
||||
|
||||
typedef iterator_adaptor<Incrementable,
|
||||
counting_iterator_policies<Incrementable>,
|
||||
Incrementable,
|
||||
const Incrementable&,
|
||||
const Incrementable*,
|
||||
typename traits::iterator_category,
|
||||
typename traits::difference_type
|
||||
> type;
|
||||
};
|
||||
|
||||
// Manufacture a counting iterator for an arbitrary incrementable type
|
||||
template <class Incrementable>
|
||||
inline typename counting_iterator_generator<Incrementable>::type
|
||||
make_counting_iterator(Incrementable x)
|
||||
{
|
||||
typedef typename counting_iterator_generator<Incrementable>::type result_t;
|
||||
return result_t(x);
|
||||
}
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_COUNTING_ITERATOR_HPP_DWA20000119
|
||||
@@ -99,17 +99,17 @@ struct half_open_range
|
||||
|
||||
public:
|
||||
typedef iter_t const_iterator;
|
||||
typedef typename iterator::value_type value_type;
|
||||
typedef typename iterator::difference_type difference_type;
|
||||
typedef typename iterator::reference reference;
|
||||
typedef typename iterator::reference const_reference;
|
||||
typedef typename iterator::pointer pointer;
|
||||
typedef typename iterator::pointer const_pointer;
|
||||
typedef typename counting_iterator_traits<Incrementable>::value_type value_type;
|
||||
typedef typename counting_iterator_traits<Incrementable>::difference_type difference_type;
|
||||
typedef typename counting_iterator_traits<Incrementable>::reference reference;
|
||||
typedef typename counting_iterator_traits<Incrementable>::reference const_reference;
|
||||
typedef typename counting_iterator_traits<Incrementable>::pointer pointer;
|
||||
typedef typename counting_iterator_traits<Incrementable>::pointer const_pointer;
|
||||
|
||||
// It would be nice to select an unsigned type, but this is appropriate
|
||||
// since the library makes an attempt to select a difference_type which can
|
||||
// hold the difference between any two iterators.
|
||||
typedef typename iterator::difference_type size_type;
|
||||
typedef typename counting_iterator_traits<Incrementable>::difference_type size_type;
|
||||
|
||||
half_open_range(Incrementable start, Incrementable finish)
|
||||
: m_start(start),
|
||||
|
||||
@@ -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/libs/utility for documentation.
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
|
||||
// Revision History
|
||||
// 12 Jan 01 added <cstddef> for std::ptrdiff_t (Jens Maurer)
|
||||
|
||||
@@ -9,21 +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
|
||||
// Added more comments in default_iterator_policies.
|
||||
// 08 Jan 2001 David Abrahams
|
||||
// Moved concept checks into a separate class, which makes MSVC
|
||||
// better at dealing with them.
|
||||
// 07 Jan 2001 David Abrahams
|
||||
// Choose proxy for operator->() only if the reference type is not a reference.
|
||||
// Updated workarounds for __MWERKS__ == 0x2406
|
||||
// 20 Dec 2001 David Abrahams
|
||||
// Adjusted is_convertible workarounds for __MWERKS__ == 0x2406
|
||||
// 03 Nov 2001 Jeremy Siek
|
||||
// Changed the named template parameter interface and internal.
|
||||
// 04 Oct 2001 Jeremy Siek
|
||||
@@ -126,12 +114,14 @@
|
||||
# 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>
|
||||
|
||||
# if BOOST_WORKAROUND(__GNUC__, == 2) && __GNUC_MINOR__ <= 96 && !defined(__STL_USE_NAMESPACES)
|
||||
// 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)
|
||||
# define BOOST_RELOPS_AMBIGUITY_BUG 1
|
||||
# endif
|
||||
|
||||
@@ -147,7 +137,7 @@ namespace boost {
|
||||
template <class Policies, class Adapted, class Traits>
|
||||
struct TrivialIteratorPoliciesConcept
|
||||
{
|
||||
typedef typename Traits::reference reference;
|
||||
typedef typename Traits::reference Reference;
|
||||
void constraints() {
|
||||
function_requires< AssignableConcept<Policies> >();
|
||||
function_requires< DefaultConstructibleConcept<Policies> >();
|
||||
@@ -157,7 +147,7 @@ struct TrivialIteratorPoliciesConcept
|
||||
const_constraints();
|
||||
}
|
||||
void const_constraints() const {
|
||||
reference r = p.dereference(x);
|
||||
Reference r = p.dereference(x);
|
||||
b = p.equal(x, x);
|
||||
ignore_unused_variable_warning(r);
|
||||
}
|
||||
@@ -173,7 +163,7 @@ struct ForwardIteratorPoliciesConcept
|
||||
{
|
||||
typedef typename Traits::iterator_category iterator_category;
|
||||
void constraints() {
|
||||
function_requires<
|
||||
function_requires<
|
||||
TrivialIteratorPoliciesConcept<Policies, Adapted, Traits>
|
||||
>();
|
||||
|
||||
@@ -191,7 +181,7 @@ struct BidirectionalIteratorPoliciesConcept
|
||||
{
|
||||
typedef typename Traits::iterator_category iterator_category;
|
||||
void constraints() {
|
||||
function_requires<
|
||||
function_requires<
|
||||
ForwardIteratorPoliciesConcept<Policies, Adapted, Traits>
|
||||
>();
|
||||
|
||||
@@ -209,7 +199,7 @@ struct RandomAccessIteratorPoliciesConcept
|
||||
typedef typename Traits::difference_type DifferenceType;
|
||||
typedef typename Traits::iterator_category iterator_category;
|
||||
void constraints() {
|
||||
function_requires<
|
||||
function_requires<
|
||||
BidirectionalIteratorPoliciesConcept<Policies, Adapted, Traits>
|
||||
>();
|
||||
|
||||
@@ -233,15 +223,9 @@ struct RandomAccessIteratorPoliciesConcept
|
||||
// class if you want to customize particular policies.
|
||||
struct default_iterator_policies
|
||||
{
|
||||
// Some of the member functions were defined static, but Borland
|
||||
// got confused and thought they were non-const. Also, Sun C++
|
||||
// does not like static function templates.
|
||||
//
|
||||
// The reason some members were defined static is because there is
|
||||
// not state (data members) needed by those members of the
|
||||
// default_iterator_policies class. If your policies class member
|
||||
// functions need to access state stored in the policies object,
|
||||
// then the member functions should not be static (they can't be).
|
||||
// Some of these members were defined static, but Borland got confused
|
||||
// and thought they were non-const. Also, Sun C++ does not like static
|
||||
// function templates.
|
||||
|
||||
template <class Base>
|
||||
void initialize(Base&)
|
||||
@@ -273,7 +257,7 @@ struct default_iterator_policies
|
||||
{ return x.base() == y.base(); }
|
||||
};
|
||||
|
||||
// putting the comparisons in a base class avoids the g++
|
||||
// putting the comparisons in a base class avoids the g++
|
||||
// ambiguous overload bug due to the relops operators
|
||||
|
||||
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
|
||||
@@ -281,7 +265,7 @@ template <class Derived, class Base>
|
||||
struct iterator_comparisons : Base { };
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator==(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator==(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
@@ -290,7 +274,7 @@ inline bool operator==(const iterator_comparisons<D1,Base1>& xb,
|
||||
}
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator!=(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator!=(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
@@ -299,7 +283,7 @@ inline bool operator!=(const iterator_comparisons<D1,Base1>& xb,
|
||||
}
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator<(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator<(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
@@ -308,16 +292,16 @@ inline bool operator<(const iterator_comparisons<D1,Base1>& xb,
|
||||
}
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator>(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator>(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
const D2& y = static_cast<const D2&>(yb);
|
||||
return x.policies().distance(y, x) > 0;
|
||||
}
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator>=(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator>=(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
@@ -326,7 +310,7 @@ inline bool operator>=(const iterator_comparisons<D1,Base1>& xb,
|
||||
}
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator<=(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator<=(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
@@ -366,14 +350,17 @@ namespace detail {
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
template <class Value, class Reference, class Pointer>
|
||||
template <class Category, class Value, class Pointer>
|
||||
struct operator_arrow_result_generator
|
||||
{
|
||||
typedef operator_arrow_proxy<Value> proxy;
|
||||
// Borland chokes unless it's an actual enum (!)
|
||||
enum { use_proxy = !boost::is_reference<Reference>::value };
|
||||
|
||||
typedef typename boost::detail::if_true<(use_proxy)>::template
|
||||
enum { is_input_iter
|
||||
= (boost::is_convertible<Category*,std::input_iterator_tag*>::value
|
||||
& !boost::is_convertible<Category*,std::forward_iterator_tag*>::value)
|
||||
};
|
||||
|
||||
typedef typename boost::detail::if_true<(is_input_iter)>::template
|
||||
then<
|
||||
proxy,
|
||||
// else
|
||||
@@ -382,7 +369,7 @@ namespace detail {
|
||||
};
|
||||
|
||||
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
||||
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// Select default pointer and reference types for adapted non-pointer
|
||||
// iterators based on the iterator and the value_type. Poor man's partial
|
||||
@@ -435,14 +422,14 @@ namespace detail {
|
||||
typename iterator_traits<Iterator>::pointer,
|
||||
Value*
|
||||
>::type pointer;
|
||||
|
||||
|
||||
typedef typename if_true<(
|
||||
::boost::is_same<Value,typename iterator_traits<Iterator>::value_type>::value
|
||||
)>::template then<
|
||||
typename iterator_traits<Iterator>::reference,
|
||||
Value&
|
||||
>::type reference;
|
||||
|
||||
|
||||
};
|
||||
# endif
|
||||
|
||||
@@ -491,8 +478,8 @@ namespace detail {
|
||||
template <class Base, class Traits>
|
||||
struct select {
|
||||
typedef typename Traits::value_type Value;
|
||||
typedef typename boost::detail::iterator_defaults<Base,Value>::pointer
|
||||
type;
|
||||
typedef typename boost::detail::iterator_defaults<Base,Value>::pointer
|
||||
type;
|
||||
};
|
||||
};
|
||||
template <> struct default_generator<default_pointer>
|
||||
@@ -502,8 +489,8 @@ namespace detail {
|
||||
template <class Base, class Traits>
|
||||
struct select {
|
||||
typedef typename Traits::value_type Value;
|
||||
typedef typename boost::detail::iterator_defaults<Base,Value>::reference
|
||||
type;
|
||||
typedef typename boost::detail::iterator_defaults<Base,Value>::reference
|
||||
type;
|
||||
};
|
||||
};
|
||||
template <> struct default_generator<default_reference>
|
||||
@@ -551,7 +538,7 @@ template <class Difference> struct difference_type_is
|
||||
{
|
||||
typedef detail::cons_type<detail::difference_type_tag, Difference> type;
|
||||
};
|
||||
template <class IteratorCategory> struct iterator_category_is
|
||||
template <class IteratorCategory> struct iterator_category_is
|
||||
: public named_template_param_base
|
||||
{
|
||||
typedef detail::cons_type<detail::iterator_category_tag, IteratorCategory> type;
|
||||
@@ -565,7 +552,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) || BOOST_WORKAROUND(__BORLANDC__, != 0)
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(__BORLANDC__)
|
||||
template <class AssocList, class Key>
|
||||
struct find_param;
|
||||
|
||||
@@ -575,7 +562,7 @@ namespace detail {
|
||||
typedef typename Head::first_type Key1;
|
||||
typedef typename Head::second_type Value;
|
||||
typedef typename if_true<(is_same<Key1, Key2>::value)>::template
|
||||
then<Value,
|
||||
then<Value,
|
||||
typename find_param<typename AssocList::second_type, Key2>::type
|
||||
>::type type;
|
||||
};
|
||||
@@ -594,7 +581,7 @@ namespace detail {
|
||||
typedef typename find_param_helper1<AssocList>::type select1;
|
||||
typedef typename select1::template select<AssocList, Key>::type type;
|
||||
};
|
||||
# else
|
||||
#else
|
||||
template <class AssocList, class Key> struct find_param;
|
||||
|
||||
template <class Key>
|
||||
@@ -611,7 +598,7 @@ namespace detail {
|
||||
struct find_param<detail::cons_type< detail::cons_type<Key1, Value>, Rest>, Key2> {
|
||||
typedef typename find_param<Rest, Key2>::type type;
|
||||
};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
struct make_named_arg {
|
||||
template <class Key, class Value>
|
||||
@@ -625,29 +612,29 @@ namespace detail {
|
||||
template <class Value>
|
||||
struct is_named_parameter
|
||||
{
|
||||
enum { value = is_convertible< typename add_reference< Value >::type, add_reference< named_template_param_base >::type >::value };
|
||||
enum { value = is_convertible<Value, named_template_param_base>::value };
|
||||
};
|
||||
|
||||
# if BOOST_WORKAROUND(__MWERKS__, <= 0x2407) // workaround for broken is_convertible implementation
|
||||
#if defined(__MWERKS__) && __MWERKS__ <= 0x2405 // 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 }; };
|
||||
template <class T> struct is_named_parameter<difference_type_is<T> > { enum { value = true }; };
|
||||
template <class T> struct is_named_parameter<iterator_category_is<T> > { enum { value = true }; };
|
||||
# endif
|
||||
#endif
|
||||
|
||||
template <class Key, class Value>
|
||||
struct make_arg {
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, > 0)
|
||||
#ifdef __BORLANDC__
|
||||
// Borland C++ doesn't like the extra indirection of is_named_parameter
|
||||
typedef typename
|
||||
typedef typename
|
||||
if_true<(is_convertible<Value,named_template_param_base>::value)>::
|
||||
template then<make_named_arg, make_key_value>::type Make;
|
||||
# else
|
||||
#else
|
||||
enum { is_named = is_named_parameter<Value>::value };
|
||||
typedef typename if_true<(is_named)>::template
|
||||
then<make_named_arg, make_key_value>::type Make;
|
||||
# endif
|
||||
#endif
|
||||
typedef typename Make::template select<Key, Value>::type type;
|
||||
};
|
||||
|
||||
@@ -691,7 +678,7 @@ namespace detail {
|
||||
class iterator_adaptor_traits_gen
|
||||
{
|
||||
// Form an associative list out of the template parameters
|
||||
// If the argument is a normal parameter (not named) then make_arg
|
||||
// If the argument is a normal parameter (not named) then make_arg
|
||||
// creates a key-value pair. If the argument is a named parameter,
|
||||
// then make_arg extracts the key-value pair defined inside the
|
||||
// named parameter.
|
||||
@@ -716,9 +703,9 @@ namespace detail {
|
||||
typedef typename resolve_default<Val, default_value_type, Base, Traits0>::type
|
||||
value_type;
|
||||
// if getting default value type from iterator_traits, then it won't be const
|
||||
typedef typename resolve_default<Diff, default_difference_type, Base,
|
||||
typedef typename resolve_default<Diff, default_difference_type, Base,
|
||||
Traits0>::type difference_type;
|
||||
typedef typename resolve_default<Cat, default_iterator_category, Base,
|
||||
typedef typename resolve_default<Cat, default_iterator_category, Base,
|
||||
Traits0>::type iterator_category;
|
||||
|
||||
typedef boost::iterator<iterator_category, value_type, difference_type,
|
||||
@@ -731,53 +718,26 @@ namespace detail {
|
||||
pointer;
|
||||
typedef typename resolve_default<Ref, default_reference, Base, Traits1>::type
|
||||
reference;
|
||||
|
||||
|
||||
public:
|
||||
typedef boost::iterator<iterator_category,
|
||||
typename remove_const<value_type>::type,
|
||||
typename remove_const<value_type>::type,
|
||||
difference_type, pointer, reference> type;
|
||||
};
|
||||
|
||||
// This is really a partial concept check for iterators. Should it
|
||||
// be moved or done differently?
|
||||
template <class Category, class Value, class Difference, class Pointer, class Reference>
|
||||
struct validator
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, is_input_or_output_iter
|
||||
= (boost::is_convertible<Category*,std::input_iterator_tag*>::value
|
||||
| boost::is_convertible<Category*,std::output_iterator_tag*>::value));
|
||||
|
||||
// Iterators should satisfy one of the known categories
|
||||
BOOST_STATIC_ASSERT(is_input_or_output_iter);
|
||||
|
||||
// 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<Category*,std::forward_iterator_tag*>::value)
|
||||
| boost::is_same<Reference,Value&>::value
|
||||
| boost::is_same<Reference,typename add_const<Value>::type&>::value));
|
||||
|
||||
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 !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
# if !defined(BOOST_MSVC)
|
||||
# define BOOST_ARG_DEPENDENT_TYPENAME typename
|
||||
# else
|
||||
# define BOOST_ARG_DEPENDENT_TYPENAME
|
||||
# endif
|
||||
|
||||
template <class T> struct undefined;
|
||||
|
||||
//============================================================================
|
||||
//iterator_adaptor - Adapts a generic piece of data as an iterator. Adaptation
|
||||
// is especially easy if the data being adapted is itself an iterator
|
||||
@@ -806,12 +766,12 @@ namespace detail {
|
||||
//
|
||||
// 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::detail::default_argument,
|
||||
class Reference = ::boost::detail::default_argument,
|
||||
class Pointer = ::boost::detail::default_argument,
|
||||
class Category = ::boost::detail::default_argument,
|
||||
class Distance = ::boost::detail::default_argument
|
||||
template <class Base, class Policies,
|
||||
class Value = detail::default_argument,
|
||||
class Reference = detail::default_argument,
|
||||
class Pointer = detail::default_argument,
|
||||
class Category = detail::default_argument,
|
||||
class Distance = detail::default_argument
|
||||
>
|
||||
struct iterator_adaptor :
|
||||
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
|
||||
@@ -838,19 +798,32 @@ struct iterator_adaptor :
|
||||
typedef Policies policies_type;
|
||||
|
||||
private:
|
||||
typedef detail::validator<
|
||||
iterator_category,value_type,difference_type,pointer,reference
|
||||
> concept_check;
|
||||
BOOST_STATIC_CONSTANT(bool, is_input_or_output_iter
|
||||
= (boost::is_convertible<iterator_category*,std::input_iterator_tag*>::value
|
||||
|| boost::is_convertible<iterator_category*,std::output_iterator_tag*>::value));
|
||||
|
||||
// Iterators should satisfy one of the known categories
|
||||
BOOST_STATIC_ASSERT(is_input_or_output_iter);
|
||||
|
||||
#if !defined(BOOST_MSVC)
|
||||
// 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));
|
||||
|
||||
// This check gives incorrect results in iter_traits_gen_test.cpp
|
||||
BOOST_STATIC_ASSERT(forward_iter_with_real_reference);
|
||||
#endif
|
||||
|
||||
public:
|
||||
iterator_adaptor()
|
||||
{
|
||||
}
|
||||
iterator_adaptor() { }
|
||||
|
||||
explicit
|
||||
iterator_adaptor(const Base& it, const Policies& p = Policies())
|
||||
: m_iter_p(it, p) {
|
||||
policies().initialize(base());
|
||||
policies().initialize(base());
|
||||
}
|
||||
|
||||
template <class Iter2, class Value2, class Pointer2, class Reference2>
|
||||
@@ -861,9 +834,9 @@ struct iterator_adaptor :
|
||||
policies().initialize(base());
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) || BOOST_WORKAROUND(__BORLANDC__, > 0)
|
||||
#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;
|
||||
@@ -873,25 +846,24 @@ struct iterator_adaptor :
|
||||
return policies().dereference(*this);
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, > 0)
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning( disable : 4284 )
|
||||
#endif
|
||||
|
||||
typename boost::detail::operator_arrow_result_generator<value_type,reference,pointer>::type
|
||||
typename boost::detail::operator_arrow_result_generator<iterator_category,value_type,pointer>::type
|
||||
operator->() const
|
||||
{ return detail::operator_arrow(*this, iterator_category()); }
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, > 0)
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
template <class diff_type>
|
||||
typename detail::dependent<diff_type, value_type>::type operator[](diff_type n) const
|
||||
value_type operator[](difference_type n) const
|
||||
{ return *(*this + n); }
|
||||
|
||||
|
||||
self& operator++() {
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, < 0x2405)
|
||||
#if !defined(__MWERKS__) || __MWERKS__ >= 0x2405
|
||||
policies().increment(*this);
|
||||
#else
|
||||
// Odd bug, MWERKS couldn't deduce the type for the member template
|
||||
@@ -902,23 +874,23 @@ struct iterator_adaptor :
|
||||
}
|
||||
|
||||
self operator++(int) { self tmp(*this); ++*this; return tmp; }
|
||||
|
||||
|
||||
self& operator--() {
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, < 0x2405)
|
||||
#if !defined(__MWERKS__) || __MWERKS__ >= 0x2405
|
||||
policies().decrement(*this);
|
||||
#else
|
||||
policies().decrement<self>(*this);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
self operator--(int) { self tmp(*this); --*this; return tmp; }
|
||||
|
||||
self& operator+=(difference_type n) {
|
||||
policies().advance(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
self& operator-=(difference_type n) {
|
||||
policies().advance(*this, -n);
|
||||
return *this;
|
||||
@@ -976,7 +948,7 @@ operator-(
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
operator==(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||
@@ -987,7 +959,7 @@ operator==(
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
operator<(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||
@@ -998,18 +970,18 @@ operator<(
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
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(y, x) > 0;
|
||||
}
|
||||
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
operator>=(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||
@@ -1020,7 +992,7 @@ operator>=(
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
operator<=(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||
@@ -1031,9 +1003,9 @@ operator<=(
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
operator!=(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
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().equal(x, y);
|
||||
@@ -1051,7 +1023,7 @@ struct transform_iterator_policies : public default_iterator_policies
|
||||
{
|
||||
transform_iterator_policies() { }
|
||||
transform_iterator_policies(const AdaptableUnaryFunction& f) : m_f(f) { }
|
||||
|
||||
|
||||
template <class IteratorAdaptor>
|
||||
typename IteratorAdaptor::reference
|
||||
dereference(const IteratorAdaptor& iter) const
|
||||
@@ -1065,7 +1037,7 @@ class transform_iterator_generator
|
||||
{
|
||||
typedef typename AdaptableUnaryFunction::result_type value_type;
|
||||
public:
|
||||
typedef iterator_adaptor<Iterator,
|
||||
typedef iterator_adaptor<Iterator,
|
||||
transform_iterator_policies<AdaptableUnaryFunction>,
|
||||
value_type, value_type, value_type*, std::input_iterator_tag>
|
||||
type;
|
||||
@@ -1104,7 +1076,7 @@ struct indirect_iterator_policies : public default_iterator_policies
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // strangely instantiated even when unused! Maybe try a recursive template someday ;-)
|
||||
# if !defined(BOOST_MSVC) // stragely 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;
|
||||
@@ -1117,12 +1089,12 @@ namespace detail {
|
||||
|
||||
template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||
class Value
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
#if !defined(BOOST_MSVC)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::value_type
|
||||
#endif
|
||||
, class Reference
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
, class Reference
|
||||
#if !defined(BOOST_MSVC)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::reference
|
||||
#else
|
||||
@@ -1130,8 +1102,8 @@ template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||
#endif
|
||||
, class Category = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<
|
||||
OuterIterator>::iterator_category
|
||||
, class Pointer
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
, class Pointer
|
||||
#if !defined(BOOST_MSVC)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::pointer
|
||||
#else
|
||||
@@ -1146,28 +1118,28 @@ struct indirect_iterator_generator
|
||||
|
||||
template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||
class Value
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
#if !defined(BOOST_MSVC)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::value_type
|
||||
#endif
|
||||
, class Reference
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
, class Reference
|
||||
#if !defined(BOOST_MSVC)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::reference
|
||||
#else
|
||||
= Value &
|
||||
#endif
|
||||
, class ConstReference = Value const&
|
||||
, class ConstReference = const Value&
|
||||
, class Category = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<
|
||||
OuterIterator>::iterator_category
|
||||
, class Pointer
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
, class Pointer
|
||||
#if !defined(BOOST_MSVC)
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::pointer
|
||||
#else
|
||||
= Value*
|
||||
#endif
|
||||
, class ConstPointer = Value const*
|
||||
, class ConstPointer = const Value*
|
||||
>
|
||||
struct indirect_iterator_pair_generator
|
||||
{
|
||||
@@ -1177,7 +1149,7 @@ struct indirect_iterator_pair_generator
|
||||
Value, ConstReference,Category,ConstPointer>::type const_iterator;
|
||||
};
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
#ifndef BOOST_MSVC
|
||||
template <class OuterIterator>
|
||||
inline typename indirect_iterator_generator<OuterIterator>::type
|
||||
make_indirect_iterator(OuterIterator base)
|
||||
@@ -1196,29 +1168,29 @@ struct reverse_iterator_policies : public default_iterator_policies
|
||||
template <class IteratorAdaptor>
|
||||
typename IteratorAdaptor::reference dereference(const IteratorAdaptor& x) const
|
||||
{ return *boost::prior(x.base()); }
|
||||
|
||||
|
||||
template <class BidirectionalIterator>
|
||||
void increment(BidirectionalIterator& x) const
|
||||
{ --x.base(); }
|
||||
|
||||
|
||||
template <class BidirectionalIterator>
|
||||
void decrement(BidirectionalIterator& x) const
|
||||
{ ++x.base(); }
|
||||
|
||||
|
||||
template <class BidirectionalIterator, class DifferenceType>
|
||||
void advance(BidirectionalIterator& x, DifferenceType n) const
|
||||
{ x.base() -= n; }
|
||||
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
typename Iterator1::difference_type distance(
|
||||
const Iterator1& x, const Iterator2& y) const
|
||||
{ return x.base() - y.base(); }
|
||||
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool equal(const Iterator1& x, const Iterator2& y) const
|
||||
{ return x.base() == y.base(); }
|
||||
};
|
||||
|
||||
|
||||
template <class BidirectionalIterator,
|
||||
class Value = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<BidirectionalIterator>::value_type,
|
||||
class Reference = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_defaults<BidirectionalIterator,Value>::reference,
|
||||
@@ -1254,7 +1226,7 @@ struct projection_iterator_policies : public default_iterator_policies
|
||||
return m_f(*iter.base());
|
||||
}
|
||||
|
||||
AdaptableUnaryFunction m_f;
|
||||
AdaptableUnaryFunction m_f;
|
||||
};
|
||||
|
||||
template <class AdaptableUnaryFunction, class Iterator>
|
||||
@@ -1283,7 +1255,7 @@ struct projection_iterator_pair_generator {
|
||||
template <class AdaptableUnaryFunction, class Iterator>
|
||||
inline typename projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type
|
||||
make_projection_iterator(
|
||||
Iterator iter,
|
||||
Iterator iter,
|
||||
const AdaptableUnaryFunction& f = AdaptableUnaryFunction())
|
||||
{
|
||||
typedef typename projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type result_t;
|
||||
@@ -1293,7 +1265,7 @@ make_projection_iterator(
|
||||
template <class AdaptableUnaryFunction, class Iterator>
|
||||
inline typename const_projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type
|
||||
make_const_projection_iterator(
|
||||
Iterator iter,
|
||||
Iterator iter,
|
||||
const AdaptableUnaryFunction& f = AdaptableUnaryFunction())
|
||||
{
|
||||
typedef typename const_projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type result_t;
|
||||
@@ -1309,7 +1281,7 @@ class filter_iterator_policies
|
||||
public:
|
||||
filter_iterator_policies() { }
|
||||
|
||||
filter_iterator_policies(const Predicate& p, const Iterator& end)
|
||||
filter_iterator_policies(const Predicate& p, const Iterator& end)
|
||||
: m_predicate(p), m_end(end) { }
|
||||
|
||||
void initialize(Iterator& x) {
|
||||
@@ -1363,7 +1335,7 @@ namespace detail {
|
||||
template <class Iterator>
|
||||
struct non_bidirectional_category
|
||||
{
|
||||
# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
# if !defined(__MWERKS__) || __MWERKS__ > 0x2405
|
||||
typedef typename reduce_to_base_class<
|
||||
std::forward_iterator_tag,
|
||||
typename iterator_traits<Iterator>::iterator_category
|
||||
@@ -1389,7 +1361,7 @@ namespace detail {
|
||||
};
|
||||
}
|
||||
|
||||
template <class Predicate, class Iterator,
|
||||
template <class Predicate, class Iterator,
|
||||
class Value = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<Iterator>::value_type,
|
||||
class Reference = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_defaults<Iterator,Value>::reference,
|
||||
class Pointer = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_defaults<Iterator,Value>::pointer,
|
||||
@@ -1399,7 +1371,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 !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // I don't have any idea why this occurs, but it doesn't seem to hurt too badly.
|
||||
#ifndef BOOST_MSVC // 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;
|
||||
|
||||
@@ -5,10 +5,6 @@
|
||||
// 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)
|
||||
@@ -78,40 +74,22 @@ void mutable_trivial_iterator_test(const Iterator i, const Iterator j, T val)
|
||||
template <class Iterator, class T>
|
||||
void input_iterator_test(Iterator i, T v1, T v2)
|
||||
{
|
||||
Iterator i1(i);
|
||||
Iterator i1 = i, i2 = i;
|
||||
|
||||
assert(i == i1);
|
||||
assert(!(i != i1));
|
||||
assert(i == i1++);
|
||||
assert(i != ++i2);
|
||||
|
||||
// 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));
|
||||
trivial_iterator_test(i, i1, v1);
|
||||
trivial_iterator_test(i, i2, v1);
|
||||
|
||||
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;
|
||||
assert(i == i1);
|
||||
assert(i == i2);
|
||||
++i1;
|
||||
++i2;
|
||||
|
||||
// how to test for operator-> ?
|
||||
trivial_iterator_test(i, i1, v2);
|
||||
trivial_iterator_test(i, i2, v2);
|
||||
}
|
||||
|
||||
// how to test output iterator?
|
||||
@@ -146,23 +124,6 @@ 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);
|
||||
|
||||
66
include/boost/permutation_iterator.hpp
Normal file
66
include/boost/permutation_iterator.hpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// (C) Copyright Toon Knapen 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.
|
||||
//
|
||||
|
||||
#include <boost/iterator_adaptors.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template < typename IndexIterator >
|
||||
struct permutation_iterator_policies : public default_iterator_policies
|
||||
{
|
||||
permutation_iterator_policies() {}
|
||||
|
||||
permutation_iterator_policies(IndexIterator order_it)
|
||||
: order_it_( order_it )
|
||||
{}
|
||||
|
||||
template <class IteratorAdaptor>
|
||||
typename IteratorAdaptor::reference dereference(const IteratorAdaptor& x) const
|
||||
{ return *(x.base() + *order_it_); }
|
||||
|
||||
template <class IteratorAdaptor>
|
||||
void increment(IteratorAdaptor&)
|
||||
{ ++order_it_; }
|
||||
|
||||
template <class IteratorAdaptor>
|
||||
void decrement(IteratorAdaptor&)
|
||||
{ --order_it_; }
|
||||
|
||||
template <class IteratorAdaptor, class DifferenceType>
|
||||
void advance(IteratorAdaptor& x, DifferenceType n)
|
||||
{ std::advance( order_it_, n ); }
|
||||
|
||||
template <class IteratorAdaptor1, class IteratorAdaptor2>
|
||||
typename IteratorAdaptor1::difference_type
|
||||
distance(const IteratorAdaptor1& x, const IteratorAdaptor2& y) const
|
||||
{ return std::distance( x.policies().order_it_, y.policies().order_it_ ); }
|
||||
|
||||
template <class IteratorAdaptor1, class IteratorAdaptor2>
|
||||
bool equal(const IteratorAdaptor1& x, const IteratorAdaptor2& y) const
|
||||
{ return x.policies().order_it_ == y.policies().order_it_; }
|
||||
|
||||
IndexIterator order_it_;
|
||||
};
|
||||
|
||||
template < typename ElementIterator, typename IndexIterator >
|
||||
struct permutation_iterator_generator
|
||||
{
|
||||
typedef boost::iterator_adaptor
|
||||
< ElementIterator,
|
||||
permutation_iterator_policies< IndexIterator >
|
||||
> type;
|
||||
};
|
||||
|
||||
template < class IndexIterator, class ElementIterator >
|
||||
inline typename permutation_iterator_generator< ElementIterator, IndexIterator >::type
|
||||
make_permutation_iterator(ElementIterator base, IndexIterator order)
|
||||
{
|
||||
typedef typename permutation_iterator_generator< ElementIterator, IndexIterator >::type result_t;
|
||||
return result_t( base, order );
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
@@ -1,59 +0,0 @@
|
||||
// (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