Compare commits

..

2 Commits

Author SHA1 Message Date
3defe4e7b7 Join ralf_grosse_kunstleve with HEAD
[SVN r9444]
2001-03-05 20:01:01 +00:00
a09aebd66b This commit was manufactured by cvs2svn to create branch
'unlabeled-1.12.2'.

[SVN r8674]
2001-01-21 05:56:58 +00:00
10 changed files with 0 additions and 2319 deletions

View File

@ -1,282 +0,0 @@
#ifndef BOOST_ITERATOR_CONCEPTS_HPP
#define BOOST_ITERATOR_CONCEPTS_HPP
#include <boost/concept_check.hpp>
#include <boost/iterator_traits.hpp>
namespace boost_concepts {
// Used a different namespace here (instead of "boost") so that the
// concept descriptions do not take for granted the names in
// namespace boost.
//===========================================================================
template <typename Iterator>
class ReadableIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
typedef typename boost::iterator_traits<Iterator>::reference reference;
typedef typename boost::iterator_traits<Iterator>::return_category
return_category;
void constraints() {
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
boost::function_requires< boost::EqualityComparableConcept<Iterator> >();
boost::function_requires< boost::DefaultConstructibleConcept<Iterator> >();
boost::function_requires<
boost::ConvertibleConcept<return_category, boost::readable_iterator_tag> >();
reference r = *i; // or perhaps read(x)
value_type v(r);
boost::ignore_unused_variable_warning(v);
}
Iterator i;
};
template <typename Iterator, typename ValueType>
class WritableIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::return_category
return_category;
void constraints() {
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
boost::function_requires< boost::EqualityComparableConcept<Iterator> >();
boost::function_requires< boost::DefaultConstructibleConcept<Iterator> >();
boost::function_requires<
boost::ConvertibleConcept<return_category, boost::writable_iterator_tag> >();
*i = v; // an alternative could be something like write(x, v)
}
ValueType v;
Iterator i;
};
template <typename Iterator>
class ConstantLvalueIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
typedef typename boost::iterator_traits<Iterator>::reference reference;
typedef typename boost::iterator_traits<Iterator>::return_category
return_category;
void constraints() {
boost::function_requires< ReadableIteratorConcept<Iterator> >();
boost::function_requires<
boost::ConvertibleConcept<return_category,
boost::constant_lvalue_iterator_tag> >();
typedef typename boost::require_same<reference, const value_type&>::type req;
reference v = *i;
boost::ignore_unused_variable_warning(v);
}
Iterator i;
};
template <typename Iterator>
class MutableLvalueIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
typedef typename boost::iterator_traits<Iterator>::reference reference;
typedef typename boost::iterator_traits<Iterator>::return_category
return_category;
void constraints() {
boost::function_requires< ReadableIteratorConcept<Iterator> >();
boost::function_requires< WritableIteratorConcept<Iterator, value_type> >();
boost::function_requires<
boost::ConvertibleConcept<return_category,
boost::constant_lvalue_iterator_tag> >();
typedef typename boost::require_same<reference, value_type&>::type req;
reference v = *i;
boost::ignore_unused_variable_warning(v);
}
Iterator i;
};
//===========================================================================
template <typename Iterator>
class SinglePassIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::motion_category
motion_category;
typedef typename boost::iterator_traits<Iterator>::difference_type
difference_type;
void constraints() {
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
boost::function_requires< boost::EqualityComparableConcept<Iterator> >();
boost::function_requires< boost::DefaultConstructibleConcept<Iterator> >();
boost::function_requires<
boost::ConvertibleConcept<motion_category,
boost::single_pass_iterator_tag> >();
// difference_type must be a signed integral type
++i;
(void)i++;
}
Iterator i;
};
template <typename Iterator>
class ForwardIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::motion_category
motion_category;
void constraints() {
boost::function_requires< SinglePassIteratorConcept<Iterator> >();
boost::function_requires<
boost::ConvertibleConcept<motion_category,
boost::forward_iterator_tag> >();
}
};
template <typename Iterator>
class BidirectionalIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::motion_category
motion_category;
void constraints() {
boost::function_requires< ForwardIteratorConcept<Iterator> >();
boost::function_requires<
boost::ConvertibleConcept<motion_category,
boost::bidirectional_iterator_tag> >();
--i;
(void)i--;
}
Iterator i;
};
template <typename Iterator>
class RandomAccessIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::motion_category
motion_category;
typedef typename boost::iterator_traits<Iterator>::difference_type
difference_type;
void constraints() {
boost::function_requires< BidirectionalIteratorConcept<Iterator> >();
boost::function_requires<
boost::ConvertibleConcept<motion_category,
boost::random_access_iterator_tag> >();
i += n;
i = i + n;
i = n + i;
i -= n;
i = i - n;
n = i - j;
}
difference_type n;
Iterator i, j;
};
//===========================================================================
template <typename Iterator>
class ReadableRandomAccessIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
typedef typename boost::iterator_traits<Iterator>::reference reference;
typedef typename boost::iterator_traits<Iterator>::difference_type
difference_type;
void constraints() {
boost::function_requires< RandomAccessIteratorConcept<Iterator> >();
boost::function_requires< ReadableIteratorConcept<Iterator> >();
reference r = i[n];
value_type v(r);
boost::ignore_unused_variable_warning(v);
}
difference_type n;
Iterator i;
};
template <typename Iterator>
class WritableRandomAccessIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
typedef typename boost::iterator_traits<Iterator>::difference_type
difference_type;
void constraints() {
boost::function_requires< RandomAccessIteratorConcept<Iterator> >();
boost::function_requires< WritableIteratorConcept<Iterator, value_type> >();
i[n] = v;
boost::ignore_unused_variable_warning(v);
}
difference_type n;
value_type v;
Iterator i;
};
template <typename Iterator>
class ConstantLvalueRandomAccessIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
typedef typename boost::iterator_traits<Iterator>::reference reference;
typedef typename boost::iterator_traits<Iterator>::difference_type
difference_type;
void constraints() {
boost::function_requires< RandomAccessIteratorConcept<Iterator> >();
boost::function_requires< ReadableIteratorConcept<Iterator> >();
typedef typename boost::require_same<reference, const value_type&>::type req;
reference v = i[n];
boost::ignore_unused_variable_warning(v);
}
difference_type n;
value_type v;
Iterator i;
};
template <typename Iterator>
class MutableLvalueRandomAccessIteratorConcept {
public:
typedef typename boost::iterator_traits<Iterator>::value_type value_type;
typedef typename boost::iterator_traits<Iterator>::reference reference;
typedef typename boost::iterator_traits<Iterator>::difference_type
difference_type;
void constraints() {
boost::function_requires< RandomAccessIteratorConcept<Iterator> >();
boost::function_requires< WritableIteratorConcept<Iterator, value_type> >();
boost::function_requires< ReadableIteratorConcept<Iterator> >();
typedef typename boost::require_same<reference, value_type&>::type req;
reference v = i[n];
boost::ignore_unused_variable_warning(v);
}
difference_type n;
value_type v;
Iterator i;
};
} // namespace boost_concepts
#endif // BOOST_ITERATOR_CONCEPTS_HPP

View File

@ -1,60 +0,0 @@
#ifndef BOOST_ITERATOR_TRAITS_HPP
#define BOOST_ITERATOR_TRAITS_HPP
#include <boost/config.hpp>
#include <boost/type_traits.hpp>
namespace boost {
template <typename Iterator>
struct iterator_traits {
typedef typename Iterator::value_type value_type;
typedef typename Iterator::reference reference;
typedef typename Iterator::pointer pointer;
typedef typename Iterator::difference_type difference_type;
typedef typename Iterator::return_category return_category;
typedef typename Iterator::motion_category motion_category;
};
// Motion Categories
struct single_pass_iterator_tag { };
struct forward_iterator_tag : public single_pass_iterator_tag { };
struct bidirectional_iterator_tag : public forward_iterator_tag { };
struct random_access_iterator_tag : public bidirectional_iterator_tag { };
// Return Type Categories
struct readable_iterator_tag { };
struct writable_iterator_tag { };
struct mutable_lvalue_iterator_tag : virtual public writable_iterator_tag,
virtual public readable_iterator_tag { };
struct constant_lvalue_iterator_tag : public readable_iterator_tag { };
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
namespace detail {
template <bool IsConst>
struct pointer_return_category {
typedef constant_lvalue_iterator_tag type;
};
template <>
struct pointer_return_category<false> {
typedef mutable_lvalue_iterator_tag type;
};
} // namespace detail
template <typename T>
struct iterator_traits<T*> {
typedef T value_type;
typedef T& reference;
typedef T* pointer;
typedef std::ptrdiff_t difference_type;
typedef typename detail::pointer_return_category<is_const<T>::value>::type
return_category;
typedef random_access_iterator_tag motion_category;
};
#endif
} // namespace boost
#endif // BOOST_ITERATOR_TRAITS_HPP

View File

@ -1,13 +0,0 @@
#include <boost/iterator_concepts.hpp>
int
main()
{
boost::function_requires<
boost_concepts::MutableLvalueRandomAccessIteratorConcept<int*> >();
boost::function_requires<
boost_concepts::ConstantLvalueRandomAccessIteratorConcept<const int*> >();
return 0;
}

View File

@ -1,203 +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
// 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);
enum { value =
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
std::numeric_limits<T>::is_specialized
#elif defined(__BORLANDC__)
::boost::is_integral<T>::value
#else
boost::is_convertible<int,T>::value && boost::is_convertible<T,int>::value
#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:
enum {numeric = detail::is_numeric<Incrementable>::value };
typedef typename detail::counting_iterator_traits_select<(
numeric
)>::template traits<Incrementable> traits;
public:
typedef Incrementable value_type;
typedef const Incrementable& reference;
typedef const value_type* pointer;
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
{
const Incrementable& dereference(type<const Incrementable&>, const Incrementable& i) const
{ return i; }
template <class Difference, class Iterator1, class Iterator2>
Difference distance(type<Difference>, const Iterator1& x,
const Iterator2& y) const
{
return boost::detail::any_distance<Difference>(x, y);//,(Difference*)());
}
};
// A type generator for counting iterators
template <class Incrementable>
struct counting_iterator_generator
{
typedef iterator_adaptor<Incrementable,
counting_iterator_policies<Incrementable>,
counting_iterator_traits<Incrementable> > 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)
{
return iterator_adaptor<Incrementable,
counting_iterator_policies<Incrementable>,
counting_iterator_traits<Incrementable> >(x);
}
} // namespace boost
#endif // BOOST_COUNTING_ITERATOR_HPP_DWA20000119

View File

@ -1,415 +0,0 @@
// (C) Copyright Jeremy Siek and David Abrahams 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 Feb 2001 Support for user-defined iterator categories (David Abrahams)
// 30 Jan 2001 Initial Checkin (David Abrahams)
#ifndef BOOST_HALF_OPEN_RANGE_HPP_
# define BOOST_HALF_OPEN_RANGE_HPP_
# include <boost/counting_iterator.hpp>
# include <functional>
# include <cassert>
# include <boost/operators.hpp>
# include <string>
# include <stdexcept>
# include <iterator>
namespace boost {
namespace detail {
// Template class choose_finish -- allows us to maintain the invariant that
// start() <= finish() on half_open_range specializations that support random
// access.
#ifdef __MWERKS__
template <class T>
const T& choose_finish(const T&, const T& finish, std::input_iterator_tag)
{
return finish;
}
template <class T>
const T& choose_finish(const T&, const T& finish, std::output_iterator_tag)
{
return finish;
}
template <class T>
const T& choose_finish(const T& start, const T& finish, std::random_access_iterator_tag)
{
return finish < start ? start : finish;
}
#else
template <bool is_random_access> struct finish_chooser;
template <>
struct finish_chooser<false>
{
template <class T>
struct rebind
{
static T choose(const T&, const T& finish)
{ return finish; }
};
};
template <>
struct finish_chooser<true>
{
template <class T>
struct rebind
{
static T choose(const T& start, const T& finish)
{ return finish < start ? start : finish; }
};
};
template <class Category, class Incrementable>
struct choose_finish
{
static const Incrementable choose(const Incrementable& start, const Incrementable& finish)
{
return finish_chooser<(
boost::is_convertible<Category,std::random_access_iterator_tag>::value
)>::template rebind<Incrementable>::choose(start, finish);
}
};
#endif
}
template <class Incrementable>
struct half_open_range
{
typedef iterator_adaptor<Incrementable,
counting_iterator_policies<Incrementable>,
counting_iterator_traits<Incrementable> > iterator;
private: // utility type definitions
typedef std::less<Incrementable> less_value;
typedef typename boost::detail::iterator_traits<iterator>::iterator_category category;
public:
typedef iterator const_iterator;
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 counting_iterator_traits<Incrementable>::difference_type size_type;
half_open_range(Incrementable start, Incrementable finish)
: m_start(start),
m_finish(
#ifndef __MWERKS__
detail::choose_finish<category,Incrementable>::choose(start, finish)
#else
detail::choose_finish(start, finish, category())
#endif
)
{}
// Implicit conversion from std::pair<Incrementable,Incrementable> allows us
// to accept the results of std::equal_range(), for example.
half_open_range(const std::pair<Incrementable,Incrementable>& x)
: m_start(x.first),
m_finish(
#ifndef __MWERKS__
detail::choose_finish<category,Incrementable>::choose(x.first, x.second)
#else
detail::choose_finish(x.first, x.second, category())
#endif
)
{}
half_open_range& operator=(const std::pair<Incrementable,Incrementable>& x)
{
m_start = x.first;
m_finish =
#ifndef __MWERKS__
detail::choose_finish<category,Incrementable>::choose(x.first, x.second);
#else
detail::choose_finish(x.first, x.second, category();
#endif
}
iterator begin() const { return iterator(m_start); }
iterator end() const { return iterator(m_finish); }
Incrementable front() const { assert(!this->empty()); return m_start; }
Incrementable back() const { assert(!this->empty()); return boost::prior(m_finish); }
Incrementable start() const { return m_start; }
Incrementable finish() const { return m_finish; }
size_type size() const { return boost::detail::distance(begin(), end()); }
bool empty() const
{
return m_finish == m_start;
}
void swap(half_open_range& x) {
std::swap(m_start, x.m_start);
std::swap(m_finish, x.m_finish);
}
public: // functions requiring random access elements
// REQUIRES: x is reachable from this->front()
bool contains(const value_type& x) const
{
BOOST_STATIC_ASSERT((boost::is_same<category, std::random_access_iterator_tag>::value));
return !less_value()(x, m_start) && less_value()(x, m_finish);
}
bool contains(const half_open_range& x) const
{
BOOST_STATIC_ASSERT((boost::is_same<category, std::random_access_iterator_tag>::value));
return x.empty() || !less_value()(x.m_start, m_start) && !less_value()(m_finish, x.m_finish);
}
bool intersects(const half_open_range& x) const
{
BOOST_STATIC_ASSERT((boost::is_same<category, std::random_access_iterator_tag>::value));
return less_value()(
less_value()(this->m_start, x.m_start) ? x.m_start : this->m_start,
less_value()(this->m_finish, x.m_finish) ? this->m_finish : x.m_finish);
}
half_open_range& operator&=(const half_open_range& x)
{
BOOST_STATIC_ASSERT((boost::is_same<category, std::random_access_iterator_tag>::value));
if (less_value()(this->m_start, x.m_start))
this->m_start = x.m_start;
if (less_value()(x.m_finish, this->m_finish))
this->m_finish = x.m_finish;
if (less_value()(this->m_finish, this->m_start))
this->m_start = this->m_finish;
return *this;
}
half_open_range& operator|=(const half_open_range& x)
{
BOOST_STATIC_ASSERT((boost::is_same<category, std::random_access_iterator_tag>::value));
if (!x.empty())
{
if (this->empty())
{
*this = x;
}
else
{
if (less_value()(x.m_start, this->m_start))
this->m_start = x.m_start;
if (less_value()(this->m_finish, x.m_finish))
this->m_finish = x.m_finish;
}
}
return *this;
}
// REQUIRES: x is reachable from this->front()
const_iterator find(const value_type& x) const
{
BOOST_STATIC_ASSERT((boost::is_same<category, std::random_access_iterator_tag>::value));
return const_iterator(this->contains(x) ? x : m_finish);
}
// REQUIRES: index >= 0 && index < size()
value_type operator[](size_type index) const
{
assert(index >= 0 && index < size());
return m_start + index;
}
value_type at(size_type index) const
{
if (index < 0 || index >= size())
throw std::out_of_range(std::string("half_open_range"));
return m_start + index;
}
private: // data members
Incrementable m_start, m_finish;
};
template <class Incrementable>
half_open_range<Incrementable> operator|(
half_open_range<Incrementable> x,
const half_open_range<Incrementable>& y)
{
return x |= y;
}
template <class Incrementable>
half_open_range<Incrementable> operator&(
half_open_range<Incrementable> x,
const half_open_range<Incrementable>& y)
{
return x &= y;
}
template <class Incrementable>
inline bool operator==(
const half_open_range<Incrementable>& x,
const half_open_range<Incrementable>& y)
{
const bool y_empty = y.empty();
return x.empty() ? y_empty : !y_empty && x.start() == y.start() && x.finish() == y.finish();
}
template <class Incrementable>
inline bool operator!=(
const half_open_range<Incrementable>& x,
const half_open_range<Incrementable>& y)
{
return !(x == y);
}
template <class Incrementable>
inline half_open_range<Incrementable>
make_half_open_range(Incrementable first, Incrementable last)
{
return half_open_range<Incrementable>(first, last);
}
template <class Incrementable>
bool intersects(
const half_open_range<Incrementable>& x,
const half_open_range<Incrementable>& y)
{
return x.intersects(y);
}
template <class Incrementable>
bool contains(
const half_open_range<Incrementable>& x,
const half_open_range<Incrementable>& y)
{
return x.contains(y);
}
} // namespace boost
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace std {
template <class Incrementable> struct less<boost::half_open_range<Incrementable> >
: binary_function<
boost::half_open_range<Incrementable>,
boost::half_open_range<Incrementable>,bool>
{
bool operator()(
const boost::half_open_range<Incrementable>& x,
const boost::half_open_range<Incrementable>& y) const
{
less<Incrementable> cmp;
return !y.empty() && (
cmp(x.start(), y.start())
|| !cmp(y.start(), x.start())
&& cmp(x.finish(), y.finish()));
}
};
template <class Incrementable> struct less_equal<boost::half_open_range<Incrementable> >
: binary_function<
boost::half_open_range<Incrementable>,
boost::half_open_range<Incrementable>,bool>
{
bool operator()(
const boost::half_open_range<Incrementable>& x,
const boost::half_open_range<Incrementable>& y) const
{
typedef boost::half_open_range<Incrementable> range;
less<range> cmp;
return !cmp(y,x);
}
};
template <class Incrementable> struct greater<boost::half_open_range<Incrementable> >
: binary_function<
boost::half_open_range<Incrementable>,
boost::half_open_range<Incrementable>,bool>
{
bool operator()(
const boost::half_open_range<Incrementable>& x,
const boost::half_open_range<Incrementable>& y) const
{
typedef boost::half_open_range<Incrementable> range;
less<range> cmp;
return cmp(y,x);
}
};
template <class Incrementable> struct greater_equal<boost::half_open_range<Incrementable> >
: binary_function<
boost::half_open_range<Incrementable>,
boost::half_open_range<Incrementable>,bool>
{
bool operator()(
const boost::half_open_range<Incrementable>& x,
const boost::half_open_range<Incrementable>& y) const
{
typedef boost::half_open_range<Incrementable> range;
less<range> cmp;
return !cmp(x,y);
}
};
} // namespace std
#else
namespace boost {
// Can't partially specialize std::less et al, so we must provide the operators
template <class Incrementable>
bool operator<(const half_open_range<Incrementable>& x,
const half_open_range<Incrementable>& y)
{
return !y.empty() && (
x.empty() || std::less<Incrementable>()(x.start(), y.start())
|| !std::less<Incrementable>()(y.start(), x.start())
&& std::less<Incrementable>()(x.finish(), y.finish()));
}
template <class Incrementable>
bool operator>(const half_open_range<Incrementable>& x,
const half_open_range<Incrementable>& y)
{
return y < x;
}
template <class Incrementable>
bool operator<=(const half_open_range<Incrementable>& x,
const half_open_range<Incrementable>& y)
{
return !(y < x);
}
template <class Incrementable>
bool operator>=(const half_open_range<Incrementable>& x,
const half_open_range<Incrementable>& y)
{
return !(x < y);
}
} // namespace boost
#endif
#endif // BOOST_HALF_OPEN_RANGE_HPP_

View File

@ -1,60 +0,0 @@
// interator.hpp workarounds for non-conforming standard libraries ---------//
// (C) Copyright Boost.org 2000. 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.
// Revision History
// 12 Jan 01 added <cstddef> for std::ptrdiff_t (Jens Maurer)
// 28 Jun 00 Workarounds to deal with known MSVC bugs (David Abrahams)
// 26 Jun 00 Initial version (Jeremy Siek)
#ifndef BOOST_ITERATOR_HPP
#define BOOST_ITERATOR_HPP
#include <iterator>
#include <cstddef> // std::ptrdiff_t
#include <boost/config.hpp>
namespace boost
{
# ifdef BOOST_NO_STD_ITERATOR
template <class Category, class T,
class Distance = std::ptrdiff_t,
class Pointer = T*, class Reference = T&>
struct iterator
{
typedef T value_type;
typedef Distance difference_type;
typedef Pointer pointer;
typedef Reference reference;
typedef Category iterator_category;
};
# else
// declare iterator_base in namespace detail to work around MSVC bugs which
// prevent derivation from an identically-named class in a different namespace.
namespace detail {
template <class Category, class T, class Distance, class Pointer, class Reference>
# if !defined(BOOST_MSVC_STD_ITERATOR)
struct iterator_base : std::iterator<Category, T, Distance, Pointer, Reference> {};
# else
struct iterator_base : std::iterator<Category, T, Distance>
{
typedef Reference reference;
typedef Pointer pointer;
typedef Distance difference_type;
};
# endif
}
template <class Category, class T, class Distance = std::ptrdiff_t,
class Pointer = T*, class Reference = T&>
struct iterator : detail::iterator_base<Category, T, Distance, Pointer, Reference> {};
# endif
} // namespace boost
#endif // BOOST_ITERATOR_HPP

View File

@ -1,998 +0,0 @@
// (C) Copyright David Abrahams 2000. 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.
//
// (C) Copyright Jeremy Siek 2000. 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:
// 09 Feb 2001 David Abrahams
// Improved interface to indirect_ and reverse_ iterators
//
// Rolled back Jeremy's new constructor for now; it was causing
// problems with counting_iterator_test
//
// Attempted fix for Borland
//
// 09 Feb 2001 Jeremy Siek
// Added iterator constructor to allow const adaptor
// from non-const adaptee.
//
// Changed make_xxx to pass iterators by-value to
// get arrays converted to pointers.
//
// Removed InnerIterator template parameter from
// indirect_iterator_generator.
//
// Rearranged parameters for make_filter_iterator
//
// 07 Feb 2001 Jeremy Siek
// Removed some const iterator adaptor generators.
//
// Added make_xxx_iterator() helper functions for remaining
// iterator adaptors.
//
// Removed some traits template parameters where they
// where no longer needed thanks to detail::iterator_traits.
//
// Moved some of the compile-time logic into enums for
// EDG compatibility.
//
// 07 Feb 2001 David Abrahams
// Removed iterator_adaptor_pair_generator and
// reverse_iterator_pair_generator (more such culling to come)
//
// Improved comments
//
// Changed all uses of std::iterator_traits as default arguments
// to boost::detail::iterator_traits for improved utility in
// non-generic contexts
//
// Fixed naming convention of non-template parameter names
//
// 06 Feb 2001 David Abrahams
// Produce operator-> proxy objects for InputIterators
//
// Added static assertions to do some basic concept checks
//
// Renamed single-type generators -> xxx_generator
// Renamed const/nonconst iterator generators -> xxx_pair_generator
//
// Added make_transform_iterator(iter, function)
//
// The existence of boost::detail::iterator_traits allowed many
// template arguments to be defaulted. Some arguments had to be
// moved to accomplish it.
//
// 04 Feb 2001 MWERKS bug workaround, concept checking for proper
// reference types (David Abrahams)
#ifndef BOOST_ITERATOR_ADAPTOR_DWA053000_HPP_
# define BOOST_ITERATOR_ADAPTOR_DWA053000_HPP_
# include <boost/iterator.hpp>
# 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/detail/iterator.hpp>
# include <boost/detail/select_type.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)
# define BOOST_RELOPS_AMBIGUITY_BUG 1
# endif
namespace boost {
//============================================================================
// Concept checking classes that express the requirements for iterator
// policies and adapted types. These classes are mostly for
// documentation purposes, and are not used in this header file. They
// merely provide a more succinct statement of what is expected of the
// iterator policies.
template <class Policies, class Adapted, class Traits>
struct TrivialIteratorPoliciesConcept
{
typedef typename Traits::reference Reference;
void constraints() {
function_requires< AssignableConcept<Policies> >();
function_requires< DefaultConstructibleConcept<Policies> >();
function_requires< AssignableConcept<Adapted> >();
function_requires< DefaultConstructibleConcept<Adapted> >();
const_constraints();
}
void const_constraints() const {
Reference r = p.dereference(type<Reference>(), x);
b = p.equal(x, x);
ignore_unused_variable_warning(r);
}
Policies p;
Adapted x;
mutable bool b;
};
// Add InputIteratorPoliciesConcept?
template <class Policies, class Adapted, class Traits>
struct ForwardIteratorPoliciesConcept
{
typedef typename Traits::iterator_category iterator_category;
void constraints() {
function_requires<
TrivialIteratorPoliciesConcept<Policies, Adapted, Traits>
>();
p.increment(x);
std::forward_iterator_tag t = iterator_category();
ignore_unused_variable_warning(t);
}
Policies p;
Adapted x;
iterator_category category;
};
template <class Policies, class Adapted, class Traits>
struct BidirectionalIteratorPoliciesConcept
{
typedef typename Traits::iterator_category iterator_category;
void constraints() {
function_requires<
ForwardIteratorPoliciesConcept<Policies, Adapted, Traits>
>();
p.decrement(x);
std::bidirectional_iterator_tag t = iterator_category();
ignore_unused_variable_warning(t);
}
Policies p;
Adapted x;
};
template <class Policies, class Adapted, class Traits>
struct RandomAccessIteratorPoliciesConcept
{
typedef typename Traits::difference_type DifferenceType;
typedef typename Traits::iterator_category iterator_category;
void constraints() {
function_requires<
BidirectionalIteratorPoliciesConcept<Policies, Adapted, Traits>
>();
p.advance(x, n);
std::random_access_iterator_tag t = iterator_category();
const_constraints();
ignore_unused_variable_warning(t);
}
void const_constraints() const {
n = p.distance(type<DifferenceType>(), x, x);
b = p.less(x, x);
}
Policies p;
Adapted x;
mutable DifferenceType n;
mutable bool b;
};
//============================================================================
// Default policies for iterator adaptors. You can use this as a base
// class if you want to customize particular policies.
struct default_iterator_policies
{
// 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 Iterator>
void initialize(Iterator&)
{ }
template <class Reference, class Iterator>
Reference dereference(type<Reference>, const Iterator& x) const
{ return *x; }
template <class Iterator>
void increment(Iterator& x)
{ ++x; }
template <class Iterator>
void decrement(Iterator& x)
{ --x; }
template <class Iterator, class DifferenceType>
void advance(Iterator& x, DifferenceType n)
{ x += n; }
template <class Difference, class Iterator1, class Iterator2>
Difference distance(type<Difference>, const Iterator1& x,
const Iterator2& y) const
{ return y - x; }
template <class Iterator1, class Iterator2>
bool equal(const Iterator1& x, const Iterator2& y) const
{ return x == y; }
template <class Iterator1, class Iterator2>
bool less(const Iterator1& x, const Iterator2& y) const
{ return x < y; }
};
// putting the comparisons in a base class avoids the g++
// ambiguous overload bug due to the relops operators
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
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,
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().equal(x.iter(), y.iter());
}
template <class D1, class D2, class Base1, class Base2>
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().equal(x.iter(), y.iter());
}
template <class D1, class D2, class Base1, class Base2>
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().less(x.iter(), y.iter());
}
template <class D1, class D2, class Base1, class Base2>
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().less(y.iter(), x.iter());
}
template <class D1, class D2, class Base1, class Base2>
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().less(x.iter(), y.iter());
}
template <class D1, class D2, class Base1, class Base2>
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().less(y.iter(), x.iter());
}
#endif
//============================================================================
// Some compilers (SGI MIPSpro 7.1.3.3) instantiate/compile member functions
// whether or not they are used. The following functions make sure that
// when the base iterators do not support particular operators, those
// operators do not get used.
namespace detail {
#if defined(__sgi) && !defined(__GNUC__)
// Dummy versions for iterators that don't support various operators
template <class Iter>
inline typename Iter::pointer
operator_arrow(const Iter&, std::output_iterator_tag) {
return typename Iter::pointer();
}
template <class Iter, class Diff>
inline void advance_impl(Iter&, Diff, std::input_iterator_tag) { }
template <class Iter, class Diff>
inline void advance_impl(Iter&, Diff, std::output_iterator_tag) { }
template <class Iter>
inline void decrement_impl(Iter&, std::input_iterator_tag) { }
template <class Iter>
inline void decrement_impl(Iter&, std::output_iterator_tag) { }
#endif
// Real versions
// operator->() needs special support for input iterators to strictly meet the
// standard's requirements. If *i is not a reference type, we must still
// produce a (constant) lvalue to which a pointer can be formed. We do that by
// returning an instantiation of this special proxy class template.
template <class T>
struct operator_arrow_proxy
{
operator_arrow_proxy(const T& x) : m_value(x) {}
const T* operator->() const { return &m_value; }
T m_value;
};
template <class Iter>
inline operator_arrow_proxy<typename Iter::value_type>
operator_arrow(const Iter& i, std::input_iterator_tag) {
return operator_arrow_proxy<typename Iter::value_type>(*i);
}
template <class Iter>
inline typename Iter::pointer
operator_arrow(const Iter& i, std::forward_iterator_tag) {
return &(*i);
}
template <class Traits>
struct operator_arrow_result_generator
{
typedef typename Traits::iterator_category category;
typedef operator_arrow_proxy<typename Traits::value_type> proxy;
typedef typename Traits::pointer pointer;
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
pointer
>::type type;
};
template <class Iter, class Diff>
inline void
advance_impl(Iter& i, Diff n, std::random_access_iterator_tag) {
i.policies().advance(i.iter(), n);
}
template <class Iter>
inline void
decrement_impl(Iter& i, std::bidirectional_iterator_tag) {
i.policies().decrement(i.iter());
}
} // namespace detail
//============================================================================
//iterator_adaptor - Adapts a generic piece of data as an iterator. Adaptation
// is especially easy if the data being adapted is itself an iterator
//
// Iterator - the iterator type being wrapped.
//
// Policies - a set of policies determining how the resulting iterator
// works.
//
// Traits - a class satisfying the same requirements as a specialization of
// std::iterator_traits for the resulting iterator.
//
template <class Iterator, class Policies,
class Traits = boost::detail::iterator_traits<Iterator>
>
struct iterator_adaptor :
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
iterator_comparisons<
iterator_adaptor<Iterator,Policies,Traits>,
#endif
boost::iterator<typename Traits::iterator_category,
typename Traits::value_type, typename Traits::difference_type,
typename Traits::pointer, typename Traits::reference>
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
>
#endif
{
typedef iterator_adaptor<Iterator, Policies, Traits> Self;
public:
typedef typename Traits::difference_type difference_type;
typedef typename Traits::value_type value_type;
typedef typename Traits::pointer pointer;
typedef typename Traits::reference reference;
typedef typename Traits::iterator_category iterator_category;
typedef Iterator iterator_type;
enum { 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);
// Iterators >= ForwardIterator must produce real references.
enum { 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) };
BOOST_STATIC_ASSERT(forward_iter_with_real_reference);
iterator_adaptor() { }
iterator_adaptor(const Iterator& it, const Policies& p = Policies())
: m_iter_p(it, p) {
policies().initialize(iter());
}
#if 0 // ndef BOOST_MSVC
// To allow construction of const adaptor from non-const adaptee.
// However, when this is defined MSVC gives ambiguous error.
template <class OtherIterator>
iterator_adaptor(const OtherIterator& it, const Policies& p = Policies())
: m_iter_p(it, p) {
policies().initialize(iter());
}
#endif
template <class OtherIter, class OtherTraits>
iterator_adaptor (const iterator_adaptor<OtherIter, Policies,
OtherTraits>& src)
: m_iter_p(src.iter(), src.policies()) {
policies().initialize(iter());
}
#ifdef BOOST_MSVC
// This is required to prevent a bug in how VC++ generates
// the assignment operator for compressed_pair.
iterator_adaptor& operator= (const iterator_adaptor& x) {
m_iter_p = x.m_iter_p;
return *this;
}
#endif
reference operator*() const {
return policies().dereference(type<reference>(), iter());
}
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning( disable : 4284 )
#endif
typename boost::detail::operator_arrow_result_generator<Traits>::type
operator->() const
{ return detail::operator_arrow(*this, iterator_category()); }
#ifdef _MSC_VER
# pragma warning(pop)
#endif
value_type operator[](difference_type n) const
{ return *(*this + n); }
Self& operator++() {
#ifdef __MWERKS__
// Odd bug, MWERKS couldn't deduce the type for the member template
// Workaround by explicitly specifying the type.
policies().increment<Iterator>(iter());
#else
policies().increment(iter());
#endif
return *this;
}
Self operator++(int) { Self tmp(*this); ++*this; return tmp; }
Self& operator--() {
detail::decrement_impl(*this, iterator_category());
return *this;
}
Self operator--(int) { Self tmp(*this); --*this; return tmp; }
Self& operator+=(difference_type n) {
detail::advance_impl(*this, n, iterator_category());
return *this;
}
Self& operator-=(difference_type n) {
detail::advance_impl(*this, -n, iterator_category());
return *this;
}
iterator_type base() const { return m_iter_p.first(); }
private:
typedef Policies policies_type;
compressed_pair<Iterator,Policies> m_iter_p;
public: // too many compilers have trouble when these are private.
Policies& policies() { return m_iter_p.second(); }
const Policies& policies() const { return m_iter_p.second(); }
Iterator& iter() { return m_iter_p.first(); }
const Iterator& iter() const { return m_iter_p.first(); }
};
template <class Iterator, class Policies, class Traits>
iterator_adaptor<Iterator,Policies,Traits>
operator-(iterator_adaptor<Iterator,Policies,Traits> p, const typename Traits::difference_type x)
{
return p -= x;
}
template <class Iterator, class Policies, class Traits>
iterator_adaptor<Iterator,Policies,Traits>
operator+(iterator_adaptor<Iterator,Policies,Traits> p, typename Traits::difference_type x)
{
return p += x;
}
template <class Iterator, class Policies, class Traits>
iterator_adaptor<Iterator,Policies,Traits>
operator+(typename Traits::difference_type x, iterator_adaptor<Iterator,Policies,Traits> p)
{
return p += x;
}
template <class Iterator1, class Iterator2, class Policies, class Traits1, class Traits2>
typename Traits1::difference_type operator-(
const iterator_adaptor<Iterator1,Policies,Traits1>& x,
const iterator_adaptor<Iterator2,Policies,Traits2>& y )
{
typedef typename Traits1::difference_type difference_type;
return x.policies().distance(type<difference_type>(), y.iter(), x.iter());
}
#ifndef BOOST_RELOPS_AMBIGUITY_BUG
template <class Iterator1, class Iterator2, class Policies, class Traits1, class Traits2>
inline bool
operator==(const iterator_adaptor<Iterator1,Policies,Traits1>& x, const iterator_adaptor<Iterator2,Policies,Traits2>& y) {
return x.policies().equal(x.iter(), y.iter());
}
template <class Iterator1, class Iterator2, class Policies, class Traits1, class Traits2>
inline bool
operator<(const iterator_adaptor<Iterator1,Policies,Traits1>& x, const iterator_adaptor<Iterator2,Policies,Traits2>& y) {
return x.policies().less(x.iter(), y.iter());
}
template <class Iterator1, class Iterator2, class Policies, class Traits1, class Traits2>
inline bool
operator>(const iterator_adaptor<Iterator1,Policies,Traits1>& x,
const iterator_adaptor<Iterator2,Policies,Traits2>& y) {
return x.policies().less(y.iter(), x.iter());
}
template <class Iterator1, class Iterator2, class Policies, class Traits1, class Traits2>
inline bool
operator>=(const iterator_adaptor<Iterator1,Policies,Traits1>& x, const iterator_adaptor<Iterator2,Policies,Traits2>& y) {
return !x.policies().less(x.iter(), y.iter());
}
template <class Iterator1, class Iterator2, class Policies, class Traits1, class Traits2>
inline bool
operator<=(const iterator_adaptor<Iterator1,Policies,Traits1>& x,
const iterator_adaptor<Iterator2,Policies,Traits2>& y) {
return !x.policies().less(y.iter(), x.iter());
}
template <class Iterator1, class Iterator2, class Policies, class Traits1, class Traits2>
inline bool
operator!=(const iterator_adaptor<Iterator1,Policies,Traits1>& x,
const iterator_adaptor<Iterator2,Policies,Traits2>& y) {
return !x.policies().equal(x.iter(), y.iter());
}
#endif
//=============================================================================
// Transform Iterator Adaptor
//
// Upon deference, apply some unary function object and return the
// result by value.
template <class AdaptableUnaryFunction>
struct transform_iterator_policies : public default_iterator_policies
{
transform_iterator_policies() { }
transform_iterator_policies(const AdaptableUnaryFunction& f) : m_f(f) { }
template <class Reference, class Iterator>
Reference dereference(type<Reference>, const Iterator& iter) const
{ return m_f(*iter); }
AdaptableUnaryFunction m_f;
};
template <class AdaptableUnaryFunction, class Iterator>
class transform_iterator_generator
{
typedef typename boost::detail::iterator_traits<Iterator>::difference_type
difference_type;
typedef typename AdaptableUnaryFunction::result_type value_type;
public:
typedef boost::iterator<std::input_iterator_tag,
value_type, difference_type, value_type*, value_type> transform_traits;
typedef iterator_adaptor<Iterator,
transform_iterator_policies<AdaptableUnaryFunction>, transform_traits>
type;
};
template <class AdaptableUnaryFunction, class Iterator>
inline typename transform_iterator_generator<AdaptableUnaryFunction,Iterator>::type
make_transform_iterator(
Iterator base,
const AdaptableUnaryFunction& f = AdaptableUnaryFunction())
{
typedef typename transform_iterator_generator<AdaptableUnaryFunction,Iterator>::type result_t;
return result_t(base, f);
}
//=============================================================================
// Indirect Iterators Adaptor
// Given a pointer to pointers (or iterator to iterators),
// apply a double dereference inside operator*().
//
// We use the term "outer" to refer to the first level iterator type
// and "inner" to refer to the second level iterator type. For
// example, given T**, T* is the inner iterator type and T** is the
// outer iterator type. Also, const T* would be the const inner
// iterator.
// We tried to implement this with transform_iterator, but that required
// using boost::remove_ref, which is not compiler portable.
struct indirect_iterator_policies : public default_iterator_policies
{
template <class Reference, class Iterator>
Reference dereference(type<Reference>, const Iterator& x) const
{ return **x; }
};
// This macro definition is only temporary in this file
# if !defined(BOOST_MSVC)
# define BOOST_ARG_DEPENDENT_TYPENAME typename
# else
# define BOOST_ARG_DEPENDENT_TYPENAME
# endif
} template <class T> struct undefined; namespace boost {
namespace detail {
# if !defined(BOOST_MSVC) // stragely instantiated even when unused! Maybe try a recursive template someday ;-)
template <class T>
struct value_type_of_value_type {
typedef typename boost::detail::iterator_traits<T>::value_type outer_value;
typedef typename boost::detail::iterator_traits<outer_value>::value_type type;
};
# endif
}
template <class OuterIterator, // Mutable or Immutable, does not matter
class Value
#if !defined(BOOST_MSVC)
= BOOST_ARG_DEPENDENT_TYPENAME detail::value_type_of_value_type<OuterIterator>::type
#endif
, class Pointer = Value*
, class Reference = Value&
>
class indirect_iterator_generator
{
typedef boost::detail::iterator_traits<OuterIterator> outer_traits;
typedef typename outer_traits::difference_type difference_type;
typedef typename outer_traits::iterator_category iterator_category;
typedef typename boost::remove_const<Value>::type value_type;
typedef Pointer pointer;
typedef Reference reference;
public:
typedef boost::iterator<iterator_category, value_type, difference_type, pointer, reference> indirect_traits;
typedef iterator_adaptor<OuterIterator, indirect_iterator_policies, indirect_traits> type;
};
template <class OuterIterator, // Mutable or Immutable, does not matter
class Value
#if !defined(BOOST_MSVC)
= BOOST_ARG_DEPENDENT_TYPENAME detail::value_type_of_value_type<OuterIterator>::type
#endif
, class Pointer = Value*
, class Reference = Value&
, class ConstPointer = const Value*
, class ConstReference = const Value&
>
struct indirect_iterator_pair_generator
{
typedef typename indirect_iterator_generator<OuterIterator,
Value, Pointer, Reference>::type iterator;
typedef typename indirect_iterator_generator<OuterIterator,
Value, ConstPointer, ConstReference>::type const_iterator;
};
// Tried to allow InnerTraits to be provided by explicit template
// argument to the function, but could not get it to work. -Jeremy Siek
template <class Value, class OuterIterator>
inline typename indirect_iterator_generator<OuterIterator,Value>::type
make_indirect_iterator(OuterIterator base, Value* = 0)
{
typedef typename indirect_iterator_generator
<OuterIterator, Value>::type result_t;
return result_t(base);
}
# if 0 // This just doesn't seem to work under any circumstances!
template <class OuterIterator>
inline typename indirect_iterator_generator<OuterIterator>::type
make_indirect_iterator(OuterIterator base)
{
typedef typename indirect_iterator_generator
<OuterIterator>::type result_t;
return result_t(base);
}
# endif
//=============================================================================
// Reverse Iterators Adaptor
struct reverse_iterator_policies : public default_iterator_policies
{
template <class Reference, class Iterator>
Reference dereference(type<Reference>, const Iterator& x) const
{ return *boost::prior(x); }
template <class Iterator>
void increment(Iterator& x) const
{ --x; }
template <class Iterator>
void decrement(Iterator& x) const
{ ++x; }
template <class Iterator, class DifferenceType>
void advance(Iterator& x, DifferenceType n) const
{ x -= n; }
template <class Difference, class Iterator1, class Iterator2>
Difference distance(type<Difference>, const Iterator1& x,
const Iterator2& y) const
{ return x - y; }
template <class Iterator1, class Iterator2>
bool equal(const Iterator1& x, const Iterator2& y) const
{ return x == y; }
template <class Iterator1, class Iterator2>
bool less(const Iterator1& x, const Iterator2& y) const
{ return y < x; }
};
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace detail {
template <bool is_pointer>
struct iterator_defaults_select
{
template <class Iterator,class Value>
struct traits
{
typedef typename boost::detail::iterator_traits<Iterator>::value_type value_type;
typedef typename boost::detail::iterator_traits<Iterator>::pointer pointer;
typedef typename boost::detail::iterator_traits<Iterator>::reference reference;
};
};
template <>
struct iterator_defaults_select<true>
{
template <class Iterator,class Value>
struct traits
{
typedef Value value_type;
typedef Value* pointer;
typedef Value& reference;
};
};
template <class Iterator,class Value>
struct iterator_defaults
{
enum { is_ptr = boost::is_pointer<Iterator>::value };
typedef iterator_defaults_select<is_ptr>::template traits<Iterator,Value> traits;
typedef typename traits::pointer pointer;
typedef typename traits::reference reference;
};
}
#endif
template <class Iterator,
class Value = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<Iterator>::value_type,
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
class Pointer = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<Iterator>::pointer,
class Reference = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<Iterator>::reference,
#else
class Pointer = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_defaults<Iterator,Value>::pointer,
class Reference = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_defaults<Iterator,Value>::reference,
#endif
class Category = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<Iterator>::iterator_category,
class Distance = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<Iterator>::difference_type
>
struct reverse_iterator_generator
{
typedef typename boost::remove_const<Value>::type value_type;
typedef boost::iterator<Category,value_type,Distance,Pointer,Reference> traits;
typedef iterator_adaptor<Iterator,reverse_iterator_policies,traits> type;
};
template <class Iterator>
inline typename reverse_iterator_generator<Iterator>::type
make_reverse_iterator(Iterator base)
{
typedef typename reverse_iterator_generator<Iterator>::type result_t;
return result_t(base);
}
//=============================================================================
// Projection Iterators Adaptor
template <class AdaptableUnaryFunction>
struct projection_iterator_policies : public default_iterator_policies
{
projection_iterator_policies() { }
projection_iterator_policies(const AdaptableUnaryFunction& f) : m_f(f) { }
template <class Reference, class Iterator>
Reference dereference (type<Reference>, Iterator const& iter) const {
return m_f(*iter);
}
AdaptableUnaryFunction m_f;
};
template <class AdaptableUnaryFunction, class Iterator>
class projection_iterator_generator {
typedef boost::detail::iterator_traits<Iterator> Traits;
typedef typename AdaptableUnaryFunction::result_type value_type;
typedef boost::iterator<typename Traits::iterator_category,
value_type, typename Traits::difference_type, value_type*, value_type&>
projection_traits;
public:
typedef iterator_adaptor<Iterator,
projection_iterator_policies<AdaptableUnaryFunction>,
projection_traits> type;
};
template <class AdaptableUnaryFunction, class Iterator>
class const_projection_iterator_generator {
typedef boost::detail::iterator_traits<Iterator> Traits;
typedef typename AdaptableUnaryFunction::result_type value_type;
typedef boost::iterator<typename Traits::iterator_category,
value_type, typename Traits::difference_type, const value_type*, const value_type&>
projection_traits;
public:
typedef iterator_adaptor<Iterator,
projection_iterator_policies<AdaptableUnaryFunction>,
projection_traits> type;
};
template <class AdaptableUnaryFunction, class Iterator, class ConstIterator>
struct projection_iterator_pair_generator {
typedef typename projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type iterator;
typedef typename const_projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type const_iterator;
};
template <class AdaptableUnaryFunction, class Iterator>
inline typename projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type
make_projection_iterator(
Iterator iter,
const AdaptableUnaryFunction& f = AdaptableUnaryFunction())
{
typedef typename projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type result_t;
return result_t(iter, f);
}
template <class AdaptableUnaryFunction, class Iterator>
inline typename const_projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type
make_const_projection_iterator(
Iterator iter,
const AdaptableUnaryFunction& f = AdaptableUnaryFunction())
{
typedef typename const_projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type result_t;
return result_t(iter, f);
}
//=============================================================================
// Filter Iterator Adaptor
template <class Predicate, class Iterator>
class filter_iterator_policies : public default_iterator_policies {
public:
filter_iterator_policies() { }
filter_iterator_policies(const Predicate& p, const Iterator& end)
: m_predicate(p), m_end(end) { }
void initialize(Iterator& x) {
advance(x);
}
// dwa 2/4/01 - The Iter template argument neccessary for compatibility with
// a MWCW bug workaround
template <class Iter>
void increment(Iter& x) {
++x;
advance(x);
}
private:
void advance(Iterator& iter)
{
while (m_end != iter && !m_predicate(*iter))
++iter;
}
Predicate m_predicate;
Iterator m_end;
};
template <class Predicate, class Iterator,
class Traits = boost::detail::iterator_traits<Iterator>
>
class filter_iterator_generator {
typedef filter_iterator_policies<Predicate, Iterator> Policies;
public:
typedef filter_iterator_policies<Predicate, Iterator> policies_type;
typedef iterator_adaptor<Iterator, Policies, Traits> type;
};
// WARNING: Do not use this three argument version of
// make_filter_iterator() if the iterator is a builtin pointer type
// and if your compiler does not support partial specialization.
// If the Predicate argument "p" is left out, an explicit template
// argument for the Predicate is required, i.e.,
// make_filter_iterator<Predicate>(f, l).
template <class Predicate, class Iterator>
inline typename filter_iterator_generator<Predicate, Iterator>::type
make_filter_iterator(Iterator first, Iterator last, const Predicate& p = Predicate())
{
typedef filter_iterator_generator<Predicate, Iterator> Gen;
typedef typename Gen::policies_type policies_t;
typedef typename Gen::type result_t;
return result_t(first, policies_t(p, last));
}
// Supply the Traits type via an exaplicit template argument, i.e.,
// make_filter_iterator<Traits>(f, l).
//
// If the Predicate argument "p" is left out, an explicit template
// argument for the Predicate is also required, i.e.,
// make_filter_iterator<Traits, Predicate>(f, l).
template <class Traits, class Predicate, class Iterator>
inline typename filter_iterator_generator<Predicate, Iterator, Traits>::type
make_filter_iterator(Iterator first, Iterator last, const Predicate& p = Predicate(), Traits* = 0)
{
typedef filter_iterator_generator<Predicate, Iterator, Traits> Gen;
typedef typename Gen::policies_type policies_t;
typedef typename Gen::type result_t;
return result_t(first, policies_t(p, last));
}
} // namespace boost
# undef BOOST_ARG_DEPENDENT_TYPENAME
#endif

View File

@ -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 */

View File

@ -1 +0,0 @@
#include <boost/iterator_adaptors.hpp>

View File

@ -1,212 +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:
// 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>
namespace boost {
// use this for the value type
struct dummyT {
dummyT() { }
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, 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);
}
// 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);
// 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