Compare commits

..

11 Commits

Author SHA1 Message Date
nobody
4bccfa8bad This commit was manufactured by cvs2svn to create tag
'Version_1_30_1'.

[SVN r19444]
2003-08-04 17:55:29 +00:00
nobody
d3339e041f This commit was manufactured by cvs2svn to create branch 'RC_1_30_0'.
[SVN r17693]
2003-03-01 19:43:06 +00:00
Beman Dawes
8dace06f04 add or update See www.boost.org comments
[SVN r16708]
2002-12-27 16:51:53 +00:00
Dave Abrahams
ef0bff57d3 Use BOOST_WORKAROUND
[SVN r16528]
2002-12-06 19:09:22 +00:00
Dave Abrahams
5bacd289b6 Roll back MPL v2 fix as it's no longer needed and was breaking Borland
[SVN r15264]
2002-09-11 14:46:40 +00:00
Dave Abrahams
77c1698c6e mpl_v2 branch checkin
[SVN r15258]
2002-09-11 05:35:41 +00:00
Dave Abrahams
2c302ee549 operator[] workaround from "Yitzhak Sapir" <yitzhaks@actimize.com>
[SVN r15244]
2002-09-09 21:15:41 +00:00
Ronald Garcia
a586f20d19 Added Shared Container Iterator adaptor to iterator adaptor library.
[SVN r15169]
2002-09-05 14:05:29 +00:00
Gennadiy Rozental
34c159dd8d Minor sunpro compartibility fix
[SVN r14741]
2002-08-08 16:42:18 +00:00
Beman Dawes
b22a3adc02 Add BOOST_NO_STD_ITERATOR_TRAITS workaround
[SVN r14663]
2002-08-03 22:45:13 +00:00
Dave Abrahams
4a24e0f401 Fixed for VC7.1
[SVN r14433]
2002-07-13 12:11:06 +00:00
5 changed files with 99 additions and 334 deletions

View File

@@ -1,229 +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.
//
// 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>
# include <boost/limits.hpp>
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(BOOST_HAS_LONG_LONG)
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 typename boost::remove_const<
Incrementable
>::type value_type;
typedef counting_iterator_traits<value_type> traits;
typedef iterator_adaptor<
value_type
, counting_iterator_policies<value_type>
, value_type
, value_type const&
, value_type const*
, 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

View File

@@ -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)

View File

@@ -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
@@ -124,14 +126,12 @@
# 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
@@ -147,7 +147,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 +157,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);
}
@@ -382,7 +382,7 @@ namespace detail {
};
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_STD_ITERATOR_TRAITS)
// Select default pointer and reference types for adapted non-pointer
// iterators based on the iterator and the value_type. Poor man's partial
@@ -565,7 +565,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 +628,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 +638,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 +761,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)
# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
# define BOOST_ARG_DEPENDENT_TYPENAME typename
# else
# define BOOST_ARG_DEPENDENT_TYPENAME
@@ -855,9 +861,9 @@ struct iterator_adaptor :
policies().initialize(base());
}
#if defined(BOOST_MSVC) || 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_pairv
// the assignment operator for compressed_pair
iterator_adaptor& operator= (const iterator_adaptor& x) {
m_iter_p = x.m_iter_p;
return *this;
@@ -867,7 +873,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 +882,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 +904,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 +1104,7 @@ struct indirect_iterator_policies : public default_iterator_policies
};
namespace detail {
# if !defined(BOOST_MSVC) // stragely 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 +1117,12 @@ namespace detail {
template <class OuterIterator, // Mutable or Immutable, does not matter
class Value
#if !defined(BOOST_MSVC)
#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)
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
OuterIterator>::reference
#else
@@ -1124,7 +1131,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)
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
OuterIterator>::pointer
#else
@@ -1139,28 +1146,28 @@ struct indirect_iterator_generator
template <class OuterIterator, // Mutable or Immutable, does not matter
class Value
#if !defined(BOOST_MSVC)
#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)
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
OuterIterator>::reference
#else
= Value &
#endif
, class ConstReference = const Value&
, class ConstReference = Value const&
, class Category = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<
OuterIterator>::iterator_category
, class Pointer
#if !defined(BOOST_MSVC)
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
OuterIterator>::pointer
#else
= Value*
#endif
, class ConstPointer = const Value*
, class ConstPointer = Value const*
>
struct indirect_iterator_pair_generator
{
@@ -1170,7 +1177,7 @@ struct indirect_iterator_pair_generator
Value, ConstReference,Category,ConstPointer>::type const_iterator;
};
#ifndef BOOST_MSVC
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
template <class OuterIterator>
inline typename indirect_iterator_generator<OuterIterator>::type
make_indirect_iterator(OuterIterator base)
@@ -1356,7 +1363,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 +1399,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));
#ifndef BOOST_MSVC // 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;

View File

@@ -1,72 +0,0 @@
// (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.
//
#ifndef boost_permutation_iterator_hpp
#define boost_permutation_iterator_hpp
#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
#endif // boost_permutation_iterator_hpp

View 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