Compare commits

..

37 Commits

Author SHA1 Message Date
Dave Abrahams
5aeb0855b4 Moved pointer parameter
[SVN r9348]
2001-02-27 02:18:48 +00:00
nobody
7a4887eff0 This commit was manufactured by cvs2svn to create branch
'moved_pointer'.

[SVN r9293]
2001-02-20 16:01:01 +00:00
Jeremy Siek
d22edf735a put policies type in private
[SVN r9290]
2001-02-20 16:00:21 +00:00
Dave Abrahams
af8dd117d5 Rolled back reverse_iterator_pair_generator again, as it doesn't save typing on a conforming compiler
[SVN r9279]
2001-02-19 20:41:22 +00:00
Dave Abrahams
149d07cda0 Fix missing comma bug
[SVN r9274]
2001-02-19 16:22:03 +00:00
Dave Abrahams
e9d9bdbb10 Reinstated reverse_iterator_pair_generator
[SVN r9264]
2001-02-18 22:21:14 +00:00
Jeremy Siek
8d8f828da5 changes to order of indirect_iterator_generator param list
[SVN r9246]
2001-02-17 22:03:06 +00:00
Jeremy Siek
fc15f5f710 added Category parameter to the indirect iterator
[SVN r9240]
2001-02-17 19:59:54 +00:00
Jeremy Siek
ef66d28b19 added "explicit" to iterator_adaptor constructor
[SVN r9234]
2001-02-17 01:44:41 +00:00
Dave Abrahams
0c8d74863f Add an implicit conversion operator to operator_arrow_proxy as CW and BCC workarounds.
[SVN r9233]
2001-02-16 23:06:57 +00:00
Jens Maurer
1c73f1f2ae made filter_iterator_generator::policies_type public
[SVN r9230]
2001-02-16 21:27:26 +00:00
Dave Abrahams
ee20a630dd Remove implication that a type generator may only generate a single type
[SVN r9221]
2001-02-16 05:24:45 +00:00
Jeremy Siek
c2472221ef made the typedef policies_type public in iterator_adaptor
and private in filter_iterator_generator


[SVN r9205]
2001-02-15 06:07:00 +00:00
Jeremy Siek
bf45977491 removed unnecessary typedefs from counting_iterator_traits
[SVN r9203]
2001-02-15 05:51:40 +00:00
Jeremy Siek
1988994bd3 added dummy_constructor to dummyT so it can be used in concept archetypes
[SVN r9181]
2001-02-13 02:03:59 +00:00
Dave Abrahams
5482763a93 added missing const qualifier
[SVN r9148]
2001-02-12 04:45:02 +00:00
Dave Abrahams
2c2a3eab21 Use new iterator_adaptor interface, Fixes for Borland.
[SVN r9131]
2001-02-11 19:36:43 +00:00
Dave Abrahams
dca20fae75 Use BOOST_STATIC_CONSTANT
[SVN r9129]
2001-02-11 19:33:47 +00:00
Dave Abrahams
e3aaf2cc91 Switch to use of BOOST_STATIC_CONSTANT where possible
[SVN r9127]
2001-02-11 19:29:28 +00:00
Jeremy Siek
ea4c7c7dd9 Removed workaround for older MIPSpro compiler. The workaround was
preventing the proper functionality of the underlying iterator being
carried forward into the iterator adaptor.

Also added is_bidirectional enum to avoid EDG compiler error.


[SVN r9123]
2001-02-11 18:57:31 +00:00
Dave Abrahams
fd6ba58d5e Borland fixes up the wazoo. It finally works!
[SVN r9114]
2001-02-11 16:09:22 +00:00
Dave Abrahams
268e70faa1 Reinstate one of John's fixes
[SVN r9113]
2001-02-11 16:06:12 +00:00
Dave Abrahams
170b44763d Clean up after John Maddocks's (finally effective!) Borland fixes
[SVN r9111]
2001-02-11 14:07:11 +00:00
John Maddock
b2701f9f78 Borland compiler fixes
[SVN r9110]
2001-02-11 12:50:06 +00:00
Dave Abrahams
ad4c5ab089 Use new iterator_adaptor<> interface
[SVN r9106]
2001-02-11 03:10:01 +00:00
Dave Abrahams
c585adde71 Removed traits argument from iterator_adaptor<> and switched to explicit trait
specification for maximum ease-of-use.

Added comments to detail::iterator_defaults<>

Began using detail::iterator_defaults<> unconditionally for code clarity

Changed uses of `Iterator' to `Base' where non-iterators can be used.


[SVN r9104]
2001-02-11 03:05:50 +00:00
Dave Abrahams
c5f24d0d72 A baby step that worked.
[SVN r9095]
2001-02-10 23:14:42 +00:00
Dave Abrahams
dbb99b1cf3 Rolled in supposed Borland fixes from John Maddock, but not seeing any improvement yet
[SVN r9093]
2001-02-10 20:23:35 +00:00
Dave Abrahams
be44a4714b Rolled in supposed Borland fixes from John Maddock, but not seeing any
improvement yet

Changed argument order to indirect_ generator, for convenience in the case of
input iterators (where Reference must be a value type).

Removed derivation of filter_iterator_policies from default_iterator_policies,
since the iterator category is likely to be reduced (we don't want to allow
illegal operations like decrement).

Support for a simpler filter iterator interface.


[SVN r9092]
2001-02-10 20:22:05 +00:00
Jeremy Siek
e9f24023d4 completely removed constructor that was #if 0'd
[SVN r9076]
2001-02-10 17:57:51 +00:00
Jens Maurer
51616fa845 removed superfluous "typename"
[SVN r9068]
2001-02-10 09:34:19 +00:00
Dave Abrahams
d7884b5613 *** empty log message ***
[SVN r9066]
2001-02-10 00:35:45 +00:00
Dave Abrahams
15b5b66776 Improved interface to indirect_ and reverse_ iterators
[SVN r9065]
2001-02-10 00:26:55 +00:00
Dave Abrahams
6f90982a45 roll back mistaken changes
[SVN r9062]
2001-02-09 21:04:09 +00:00
Dave Abrahams
bfda34e9e0 try a better interface to indirect iterators
[SVN r9060]
2001-02-09 19:26:19 +00:00
Dave Abrahams
5bfc03ed4a Cleaned up redundant test is_integral<T> || is_same<T,char> -> is_integral<T>
[SVN r9059]
2001-02-09 15:43:57 +00:00
Dave Abrahams
490bee3a06 Factored out is_numeric computation. Borland still unhappy :(
[SVN r9057]
2001-02-09 15:21:02 +00:00
2 changed files with 630 additions and 357 deletions

View File

@@ -0,0 +1,215 @@
// (C) Copyright David Abrahams and Jeremy Siek 2000-2001. Permission to copy,
// use, modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided "as is"
// without express or implied warranty, and with no claim as to its suitability
// for any purpose.
//
// See http://www.boost.org for most recent version including documentation.
//
// Supplies:
//
// template <class Incrementable> class counting_iterator_traits;
// template <class Incrementable> class counting_iterator_policies;
//
// Iterator traits and policies for adapted iterators whose dereferenced
// value progresses through consecutive values of Incrementable when the
// iterator is derferenced.
//
// template <class Incrementable> struct counting_iterator_generator;
//
// A "type generator" whose nested type "type" is a counting iterator as
// described above.
//
// template <class Incrementable>
// typename counting_iterator_generator<Incrementable>::type
// make_counting_iterator(Incrementable);
//
// A function which produces an adapted counting iterator over values of
// Incrementable.
//
// Revision History
// 14 Feb 2001 Removed unnecessary typedefs from counting_iterator_traits
// (Jeremy Siek)
// 11 Feb 2001 Use BOOST_STATIC_CONSTANT (Dave Abrahams)
// 11 Feb 2001 Clean up after John Maddocks's (finally effective!) Borland
// fixes (David Abrahams).
// 10 Feb 2001 Use new iterator_adaptor<> interface (David Abrahams)
// 10 Feb 2001 Rolled in supposed Borland fixes from John Maddock, but not
// seeing any improvement yet (David Abrahams)
// 09 Feb 2001 Factored out is_numeric computation. Borland still
// unhappy :( (David Abrahams)
// 08 Feb 2001 Beginning of a failed attempt to appease Borland
// (David Abrahams)
// 07 Feb 2001 rename counting_iterator() -> make_counting_iterator()
// (David Abrahams)
// 04 Feb 2001 Added counting_iterator_generator; updated comments
// (David Abrahams)
// 24 Jan 2001 initial revision, based on Jeremy Siek's
// boost/pending/integer_range.hpp (David Abrahams)
#ifndef BOOST_COUNTING_ITERATOR_HPP_DWA20000119
# define BOOST_COUNTING_ITERATOR_HPP_DWA20000119
# include <boost/config.hpp>
# include <boost/detail/iterator.hpp>
# include <boost/iterator_adaptors.hpp>
# include <boost/type_traits.hpp>
# include <boost/detail/numeric_traits.hpp>
# include <boost/static_assert.hpp>
# ifndef BOOST_NO_LIMITS
# include <limits>
# endif
namespace boost {
namespace detail {
// Template class counting_iterator_traits_select -- choose an
// iterator_category and difference_type for a counting_iterator at
// compile-time based on whether or not it wraps an integer or an iterator,
// using "poor man's partial specialization".
template <bool is_integer> struct counting_iterator_traits_select;
// Incrementable is an iterator type
template <>
struct counting_iterator_traits_select<false>
{
template <class Incrementable>
struct traits
{
private:
typedef boost::detail::iterator_traits<Incrementable> x;
public:
typedef typename x::iterator_category iterator_category;
typedef typename x::difference_type difference_type;
};
};
// Incrementable is a numeric type
template <>
struct counting_iterator_traits_select<true>
{
template <class Incrementable>
struct traits
{
typedef typename
boost::detail::numeric_traits<Incrementable>::difference_type
difference_type;
typedef std::random_access_iterator_tag iterator_category;
};
};
// Template class distance_policy_select -- choose a policy for computing the
// distance between counting_iterators at compile-time based on whether or not
// the iterator wraps an integer or an iterator, using "poor man's partial
// specialization".
template <bool is_integer> struct distance_policy_select;
// A policy for wrapped iterators
template <>
struct distance_policy_select<false>
{
template <class Distance, class Incrementable>
struct policy {
static Distance distance(Incrementable x, Incrementable y)
{ return boost::detail::distance(x, y); }
};
};
// A policy for wrapped numbers
template <>
struct distance_policy_select<true>
{
template <class Distance, class Incrementable>
struct policy {
static Distance distance(Incrementable x, Incrementable y)
{ return numeric_distance(x, y); }
};
};
// Try to detect numeric types at compile time in ways compatible with the
// limitations of the compiler and library.
template <class T>
struct is_numeric {
// For a while, this wasn't true, but we rely on it below. This is a regression assert.
BOOST_STATIC_ASSERT(::boost::is_integral<char>::value);
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits<T>::is_specialized);
# 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
{
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 counting_iterator_traits<Incrementable> traits;
typedef iterator_adaptor<Incrementable,
counting_iterator_policies<Incrementable>,
Incrementable,
const Incrementable&,
typename traits::iterator_category,
typename traits::difference_type,
const 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)
{
typedef typename counting_iterator_generator<Incrementable>::type result_t;
return result_t(x);
}
} // namespace boost
#endif // BOOST_COUNTING_ITERATOR_HPP_DWA20000119

File diff suppressed because it is too large Load Diff