forked from boostorg/iterator
change to new/old category recognition code
[SVN r613]
This commit is contained in:
@@ -12,7 +12,8 @@
|
|||||||
#include <boost/type_traits/cv_traits.hpp>
|
#include <boost/type_traits/cv_traits.hpp>
|
||||||
#include <boost/pending/ct_if.hpp>
|
#include <boost/pending/ct_if.hpp>
|
||||||
#include <boost/detail/iterator.hpp>
|
#include <boost/detail/iterator.hpp>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/mpl/apply_if.hpp>
|
||||||
|
#include <boost/type_traits/ice.hpp>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
@@ -119,6 +120,7 @@ namespace boost {
|
|||||||
>::type type;
|
>::type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
struct return_category_from_old_traits {
|
struct return_category_from_old_traits {
|
||||||
template <typename Iterator> class bind {
|
template <typename Iterator> class bind {
|
||||||
typedef boost::detail::iterator_traits<Iterator> OldTraits;
|
typedef boost::detail::iterator_traits<Iterator> OldTraits;
|
||||||
@@ -157,9 +159,25 @@ namespace boost {
|
|||||||
public:
|
public:
|
||||||
typedef typename Choice:: template bind<Iterator>::type type;
|
typedef typename Choice:: template bind<Iterator>::type type;
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
type_traits::yes_type is_new_iter_cat(T*, typename T::traversal* = 0) { }
|
||||||
|
|
||||||
|
type_traits::no_type is_new_iter_cat(...) { }
|
||||||
|
|
||||||
|
template <class Tag>
|
||||||
|
struct is_new_iterator_tag
|
||||||
|
{
|
||||||
|
static Tag* t;
|
||||||
|
enum { value = sizeof(is_new_iter_cat(t)) == sizeof(type_traits::yes_type) };
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
#if 0
|
||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
struct return_category {
|
struct return_category {
|
||||||
typedef typename detail::choose_return_category<Iterator>::type type;
|
typedef typename detail::choose_return_category<Iterator>::type type;
|
||||||
@@ -170,6 +188,56 @@ namespace boost {
|
|||||||
struct traversal_category {
|
struct traversal_category {
|
||||||
typedef typename detail::choose_traversal_category<Iterator>::type type;
|
typedef typename detail::choose_traversal_category<Iterator>::type type;
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template <class NewCategoryTag>
|
||||||
|
struct get_return_category {
|
||||||
|
typedef typename NewCategoryTag::returns type;
|
||||||
|
};
|
||||||
|
template <class NewCategoryTag>
|
||||||
|
struct get_traversal_category {
|
||||||
|
typedef typename NewCategoryTag::traversal type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class CategoryTag, class Value>
|
||||||
|
struct return_category_tag
|
||||||
|
{
|
||||||
|
typedef typename
|
||||||
|
mpl::apply_if<
|
||||||
|
is_new_iterator_tag<CategoryTag>
|
||||||
|
, get_return_category<CategoryTag>
|
||||||
|
, iter_category_to_return<CategoryTag, Value>
|
||||||
|
>::type type;
|
||||||
|
};
|
||||||
|
template <class CategoryTag, class Value>
|
||||||
|
struct traversal_category_tag
|
||||||
|
{
|
||||||
|
typedef typename
|
||||||
|
mpl::apply_if<
|
||||||
|
is_new_iterator_tag<CategoryTag>
|
||||||
|
, get_traversal_category<CategoryTag>
|
||||||
|
, iter_category_to_return<CategoryTag, Value>
|
||||||
|
>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template <class Iterator>
|
||||||
|
struct return_category {
|
||||||
|
typedef typename detail::return_category_tag<
|
||||||
|
typename detail::iterator_traits<Iterator>::iterator_category
|
||||||
|
, typename detail::iterator_traits<Iterator>::value_type>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class Iterator>
|
||||||
|
struct traversal_category {
|
||||||
|
typedef typename detail::traversal_category_tag<
|
||||||
|
typename detail::iterator_traits<Iterator>::iterator_category
|
||||||
|
, typename detail::iterator_traits<Iterator>::value_type>::type type;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||||
|
|
||||||
|
@@ -26,8 +26,7 @@ namespace boost_concepts {
|
|||||||
public:
|
public:
|
||||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||||
typedef typename std::iterator_traits<Iterator>::iterator_category iterator_category;
|
typedef typename boost::return_category<Iterator>::type return_category;
|
||||||
typedef typename iterator_category::returns return_category;
|
|
||||||
|
|
||||||
void constraints() {
|
void constraints() {
|
||||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
||||||
@@ -48,8 +47,7 @@ namespace boost_concepts {
|
|||||||
template <typename Iterator, typename ValueType>
|
template <typename Iterator, typename ValueType>
|
||||||
class WritableIteratorConcept {
|
class WritableIteratorConcept {
|
||||||
public:
|
public:
|
||||||
typedef typename std::iterator_traits<Iterator>::iterator_category iterator_category;
|
typedef typename boost::return_category<Iterator>::type return_category;
|
||||||
typedef typename iterator_category::returns return_category;
|
|
||||||
|
|
||||||
void constraints() {
|
void constraints() {
|
||||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
||||||
@@ -71,8 +69,7 @@ namespace boost_concepts {
|
|||||||
public:
|
public:
|
||||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||||
typedef typename std::iterator_traits<Iterator>::iterator_category iterator_category;
|
typedef typename boost::return_category<Iterator>::type return_category;
|
||||||
typedef typename iterator_category::returns return_category;
|
|
||||||
|
|
||||||
void constraints() {
|
void constraints() {
|
||||||
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
||||||
@@ -94,8 +91,7 @@ namespace boost_concepts {
|
|||||||
public:
|
public:
|
||||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||||
typedef typename std::iterator_traits<Iterator>::iterator_category iterator_category;
|
typedef typename boost::return_category<Iterator>::type return_category;
|
||||||
typedef typename iterator_category::returns return_category;
|
|
||||||
|
|
||||||
void constraints() {
|
void constraints() {
|
||||||
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
||||||
@@ -119,8 +115,7 @@ namespace boost_concepts {
|
|||||||
template <typename Iterator>
|
template <typename Iterator>
|
||||||
class ForwardTraversalConcept {
|
class ForwardTraversalConcept {
|
||||||
public:
|
public:
|
||||||
typedef typename std::iterator_traits<Iterator>::iterator_category iterator_category;
|
typedef typename boost::traversal_category<Iterator>::type traversal_category;
|
||||||
typedef typename iterator_category::traversal traversal_category;
|
|
||||||
|
|
||||||
void constraints() {
|
void constraints() {
|
||||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
||||||
@@ -139,8 +134,7 @@ namespace boost_concepts {
|
|||||||
template <typename Iterator>
|
template <typename Iterator>
|
||||||
class BidirectionalTraversalConcept {
|
class BidirectionalTraversalConcept {
|
||||||
public:
|
public:
|
||||||
typedef typename std::iterator_traits<Iterator>::iterator_category iterator_category;
|
typedef typename boost::traversal_category<Iterator>::type traversal_category;
|
||||||
typedef typename iterator_category::traversal traversal_category;
|
|
||||||
|
|
||||||
void constraints() {
|
void constraints() {
|
||||||
boost::function_requires< ForwardTraversalConcept<Iterator> >();
|
boost::function_requires< ForwardTraversalConcept<Iterator> >();
|
||||||
@@ -157,8 +151,7 @@ namespace boost_concepts {
|
|||||||
template <typename Iterator>
|
template <typename Iterator>
|
||||||
class RandomAccessTraversalConcept {
|
class RandomAccessTraversalConcept {
|
||||||
public:
|
public:
|
||||||
typedef typename std::iterator_traits<Iterator>::iterator_category iterator_category;
|
typedef typename boost::traversal_category<Iterator>::type traversal_category;
|
||||||
typedef typename iterator_category::traversal traversal_category;
|
|
||||||
typedef typename std::iterator_traits<Iterator>::difference_type
|
typedef typename std::iterator_traits<Iterator>::difference_type
|
||||||
difference_type;
|
difference_type;
|
||||||
|
|
||||||
|
@@ -6,14 +6,13 @@
|
|||||||
|
|
||||||
#include <boost/iterator/iterator_concepts.hpp>
|
#include <boost/iterator/iterator_concepts.hpp>
|
||||||
#include <boost/operators.hpp>
|
#include <boost/operators.hpp>
|
||||||
|
#include <boost/static_assert.hpp> // remove
|
||||||
|
|
||||||
struct new_iterator
|
struct new_iterator
|
||||||
: public boost::iterator<std::random_access_iterator_tag, int>,
|
: public boost::iterator< boost::iterator_tag<
|
||||||
public boost::new_iterator_base
|
boost::mutable_lvalue_iterator_tag
|
||||||
|
, boost::random_access_traversal_tag>, int>
|
||||||
{
|
{
|
||||||
typedef boost::random_access_traversal_tag traversal_category;
|
|
||||||
typedef boost::mutable_lvalue_iterator_tag return_category;
|
|
||||||
|
|
||||||
int& operator*() const { return *m_x; }
|
int& operator*() const { return *m_x; }
|
||||||
new_iterator& operator++() { return *this; }
|
new_iterator& operator++() { return *this; }
|
||||||
new_iterator operator++(int) { return *this; }
|
new_iterator operator++(int) { return *this; }
|
||||||
@@ -58,22 +57,22 @@ main()
|
|||||||
boost::function_requires<
|
boost::function_requires<
|
||||||
boost_concepts::MutableLvalueIteratorConcept<int*> >();
|
boost_concepts::MutableLvalueIteratorConcept<int*> >();
|
||||||
boost::function_requires<
|
boost::function_requires<
|
||||||
boost_concepts::RandomAccessIteratorConcept<int*> >();
|
boost_concepts::RandomAccessTraversalConcept<int*> >();
|
||||||
|
|
||||||
boost::function_requires<
|
boost::function_requires<
|
||||||
boost_concepts::ConstantLvalueIteratorConcept<const int*> >();
|
boost_concepts::ConstantLvalueIteratorConcept<const int*> >();
|
||||||
boost::function_requires<
|
boost::function_requires<
|
||||||
boost_concepts::RandomAccessIteratorConcept<const int*> >();
|
boost_concepts::RandomAccessTraversalConcept<const int*> >();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
boost::function_requires<
|
boost::function_requires<
|
||||||
boost_concepts::MutableLvalueIteratorConcept<new_iterator> >();
|
boost_concepts::MutableLvalueIteratorConcept<new_iterator> >();
|
||||||
boost::function_requires<
|
boost::function_requires<
|
||||||
boost_concepts::RandomAccessIteratorConcept<new_iterator> >();
|
boost_concepts::RandomAccessTraversalConcept<new_iterator> >();
|
||||||
|
|
||||||
boost::function_requires<
|
boost::function_requires<
|
||||||
boost_concepts::MutableLvalueIteratorConcept<old_iterator> >();
|
boost_concepts::MutableLvalueIteratorConcept<old_iterator> >();
|
||||||
boost::function_requires<
|
boost::function_requires<
|
||||||
boost_concepts::RandomAccessIteratorConcept<old_iterator> >();
|
boost_concepts::RandomAccessTraversalConcept<old_iterator> >();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user