mirror of
https://github.com/boostorg/iterator.git
synced 2025-06-30 22:41:10 +02:00
Compare commits
18 Commits
boost-1.21
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
edcea5d276 | |||
81e3df2b36 | |||
ac05307515 | |||
552a1e6785 | |||
134b8b51aa | |||
efecfd17b9 | |||
799158841e | |||
582ebfd054 | |||
42e4db1539 | |||
d7023154a3 | |||
9582b2223c | |||
d7908fb81f | |||
e48cdcb94f | |||
0846ad5fd0 | |||
84663ff2e2 | |||
6de1934420 | |||
a110b9fd27 | |||
eb06c122d1 |
@ -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
|
@ -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
|
@ -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;
|
||||
}
|
@ -656,7 +656,7 @@ struct iterator_adaptor :
|
||||
return policies().dereference(type<reference>(), iter());
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning( disable : 4284 )
|
||||
#endif
|
||||
@ -665,7 +665,7 @@ struct iterator_adaptor :
|
||||
operator->() const
|
||||
{ return detail::operator_arrow(*this, iterator_category()); }
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
@ -1129,6 +1129,7 @@ namespace detail {
|
||||
# else
|
||||
// is_convertible doesn't work with MWERKS
|
||||
typedef typename iterator_traits<Iterator>::iterator_category input_category;
|
||||
public:
|
||||
typedef typename if_true<(
|
||||
boost::is_same<input_category,std::random_access_iterator_tag>::value
|
||||
|| boost::is_same<input_category,std::bidirectional_iterator_tag>::value
|
||||
|
Reference in New Issue
Block a user