mirror of
https://github.com/boostorg/iterator.git
synced 2025-07-21 00:22:11 +02:00
Factored counting_iterator stuff into boost/counting_iterator.hpp
[SVN r8935]
This commit is contained in:
@ -1,63 +1,27 @@
|
|||||||
// (C) Copyright David Abrahams 2000. Permission to copy, use,
|
// (C) Copyright David Abrahams and Jeremy Siek 2000-2001. Permission to copy,
|
||||||
// modify, sell and distribute this software is granted provided this
|
// use, modify, sell and distribute this software is granted provided this
|
||||||
// copyright notice appears in all copies. This software is provided
|
// copyright notice appears in all copies. This software is provided "as is"
|
||||||
// "as is" without express or implied warranty, and with no claim as
|
// without express or implied warranty, and with no claim as to its suitability
|
||||||
// to its suitability for any purpose.
|
// for any purpose.
|
||||||
//
|
//
|
||||||
// (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify,
|
// Revision History:
|
||||||
// sell and distribute this software is granted provided this
|
// 04 Jan 2001 Factored counting_iterator stuff into
|
||||||
// copyright notice appears in all copies. This software is provided
|
// boost/counting_iterator.hpp (David Abrahams)
|
||||||
// "as is" without express or implied warranty, and with no claim as
|
|
||||||
// to its suitability for any purpose.
|
|
||||||
|
|
||||||
#ifndef BOOST_INTEGER_RANGE_HPP_
|
#ifndef BOOST_INTEGER_RANGE_HPP_
|
||||||
#define BOOST_INTEGER_RANGE_HPP_
|
#define BOOST_INTEGER_RANGE_HPP_
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/counting_iterator.hpp>
|
||||||
#if 1
|
|
||||||
// Still evaluating whether VC++ can handle this.
|
|
||||||
#define BOOST_USE_ITERATOR_ADAPTORS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BOOST_USE_ITERATOR_ADAPTORS
|
|
||||||
#include <boost/pending/iterator_adaptors.hpp>
|
|
||||||
#else
|
|
||||||
#include <boost/pending/detail/int_iterator.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Counting Iterator and Integer Range Class
|
// Counting Iterator and Integer Range Class
|
||||||
|
|
||||||
#ifdef BOOST_USE_ITERATOR_ADAPTORS
|
|
||||||
template <class IntegerType>
|
|
||||||
struct counting_iterator_policies : public default_iterator_policies
|
|
||||||
{
|
|
||||||
IntegerType
|
|
||||||
dereference(type<IntegerType>, const IntegerType& i) const
|
|
||||||
{ return i; }
|
|
||||||
};
|
|
||||||
template <class IntegerType>
|
|
||||||
struct counting_iterator_traits {
|
|
||||||
typedef IntegerType value_type;
|
|
||||||
typedef IntegerType reference;
|
|
||||||
typedef value_type* pointer;
|
|
||||||
typedef std::ptrdiff_t difference_type;
|
|
||||||
typedef std::random_access_iterator_tag iterator_category;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <class IntegerType>
|
template <class IntegerType>
|
||||||
struct integer_range {
|
struct integer_range {
|
||||||
#ifdef BOOST_USE_ITERATOR_ADAPTORS
|
typedef typename counting_iterator_generator<IntegerType>::type iterator;
|
||||||
typedef iterator_adaptor<IntegerType,
|
|
||||||
counting_iterator_policies<IntegerType>,
|
|
||||||
counting_iterator_traits<IntegerType> > iterator;
|
|
||||||
#else
|
|
||||||
typedef int_iterator<IntegerType> iterator;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef iterator const_iterator;
|
typedef iterator const_iterator;
|
||||||
typedef IntegerType value_type;
|
typedef IntegerType value_type;
|
||||||
@ -92,8 +56,4 @@ make_integer_range(IntegerType first, IntegerType last)
|
|||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#ifdef BOOST_USE_ITERATOR_ADAPTORS
|
|
||||||
#undef BOOST_USE_ITERATOR_ADAPTORS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // BOOST_INTEGER_RANGE_HPP_
|
#endif // BOOST_INTEGER_RANGE_HPP_
|
||||||
|
Reference in New Issue
Block a user