forked from boostorg/iterator
merging updates
[SVN r21940]
This commit is contained in:
@ -60,19 +60,13 @@ namespace boost_concepts {
|
|||||||
class ReadableIteratorConcept {
|
class ReadableIteratorConcept {
|
||||||
public:
|
public:
|
||||||
typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::value_type value_type;
|
typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::value_type value_type;
|
||||||
typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference reference;
|
|
||||||
|
|
||||||
void constraints() {
|
void constraints() {
|
||||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
boost::function_requires< boost::AssignableConcept<Iterator> >();
|
||||||
boost::function_requires< boost::EqualityComparableConcept<Iterator> >();
|
boost::function_requires< boost::CopyConstructibleConcept<Iterator> >();
|
||||||
boost::function_requires<
|
|
||||||
boost::DefaultConstructibleConcept<Iterator> >();
|
|
||||||
|
|
||||||
reference r = *i; // or perhaps read(x)
|
value_type v = *i;
|
||||||
value_type v = r;
|
|
||||||
value_type v2 = *i;
|
|
||||||
boost::ignore_unused_variable_warning(v);
|
boost::ignore_unused_variable_warning(v);
|
||||||
boost::ignore_unused_variable_warning(v2);
|
|
||||||
}
|
}
|
||||||
Iterator i;
|
Iterator i;
|
||||||
};
|
};
|
||||||
@ -85,12 +79,8 @@ namespace boost_concepts {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
void constraints() {
|
void constraints() {
|
||||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
boost::function_requires< boost::CopyConstructibleConcept<Iterator> >();
|
||||||
boost::function_requires< boost::EqualityComparableConcept<Iterator> >();
|
*i = v;
|
||||||
boost::function_requires<
|
|
||||||
boost::DefaultConstructibleConcept<Iterator> >();
|
|
||||||
|
|
||||||
*i = v; // a good alternative could be something like write(x, v)
|
|
||||||
}
|
}
|
||||||
ValueType v;
|
ValueType v;
|
||||||
Iterator i;
|
Iterator i;
|
||||||
@ -112,20 +102,11 @@ namespace boost_concepts {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::value_type value_type;
|
typedef typename boost::detail::iterator_traits<Iterator>::value_type value_type;
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::reference reference;
|
|
||||||
|
|
||||||
void constraints()
|
void constraints()
|
||||||
{
|
{
|
||||||
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
||||||
|
const value_type& v = *i;
|
||||||
typedef boost::mpl::or_<
|
|
||||||
boost::is_same<reference, value_type&>
|
|
||||||
, boost::is_same<reference, value_type const&>
|
|
||||||
> correct_reference;
|
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(correct_reference::value);
|
|
||||||
|
|
||||||
reference v = *i;
|
|
||||||
boost::ignore_unused_variable_warning(v);
|
boost::ignore_unused_variable_warning(v);
|
||||||
}
|
}
|
||||||
Iterator i;
|
Iterator i;
|
||||||
@ -159,9 +140,8 @@ namespace boost_concepts {
|
|||||||
typedef typename boost::iterator_traversal<Iterator>::type traversal_category;
|
typedef typename boost::iterator_traversal<Iterator>::type traversal_category;
|
||||||
|
|
||||||
void constraints() {
|
void constraints() {
|
||||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
boost::function_requires< boost::AssignableConcept<Iterator> >();
|
||||||
boost::function_requires<
|
boost::function_requires< boost::CopyConstructibleConcept<Iterator> >();
|
||||||
boost::DefaultConstructibleConcept<Iterator> >();
|
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(
|
BOOST_STATIC_ASSERT(
|
||||||
(boost::is_convertible<
|
(boost::is_convertible<
|
||||||
@ -203,6 +183,8 @@ namespace boost_concepts {
|
|||||||
|
|
||||||
void constraints() {
|
void constraints() {
|
||||||
boost::function_requires< SinglePassIteratorConcept<Iterator> >();
|
boost::function_requires< SinglePassIteratorConcept<Iterator> >();
|
||||||
|
boost::function_requires<
|
||||||
|
boost::DefaultConstructibleConcept<Iterator> >();
|
||||||
|
|
||||||
typedef boost::mpl::and_<
|
typedef boost::mpl::and_<
|
||||||
boost::is_integral<difference_type>,
|
boost::is_integral<difference_type>,
|
||||||
@ -271,125 +253,74 @@ namespace boost_concepts {
|
|||||||
//===========================================================================
|
//===========================================================================
|
||||||
// Iterator Interoperability Concept
|
// Iterator Interoperability Concept
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
|
||||||
|
|
||||||
template <typename TraversalTag>
|
|
||||||
struct Operations;
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct Operations<boost::incrementable_traversal_tag>
|
|
||||||
{
|
{
|
||||||
template <typename Iterator1, typename Iterator2>
|
|
||||||
static void constraints(Iterator1 const& i1, Iterator2 const& i2)
|
|
||||||
{
|
|
||||||
// no interoperability constraints
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
template <typename Iterator1, typename Iterator2>
|
||||||
struct Operations<boost::single_pass_traversal_tag>
|
void interop_single_pass_constraints(Iterator1 const& i1, Iterator2 const& i2)
|
||||||
{
|
|
||||||
template <typename Iterator1, typename Iterator2>
|
|
||||||
static void constraints(Iterator1 const& i1, Iterator2 const& i2)
|
|
||||||
{
|
|
||||||
Operations<boost::incrementable_traversal_tag>::constraints(i1, i2);
|
|
||||||
i1 == i2;
|
|
||||||
i1 != i2;
|
|
||||||
|
|
||||||
i2 == i1;
|
|
||||||
i2 != i1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct Operations<boost::forward_traversal_tag>
|
|
||||||
{
|
|
||||||
template <typename Iterator1, typename Iterator2>
|
|
||||||
static void constraints(Iterator1 const& i1, Iterator2 const& i2)
|
|
||||||
{
|
|
||||||
Operations<boost::single_pass_traversal_tag>::constraints(i1, i2);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct Operations<boost::bidirectional_traversal_tag>
|
|
||||||
{
|
|
||||||
template <typename Iterator1, typename Iterator2>
|
|
||||||
static void constraints(Iterator1 const& i1, Iterator2 const& i2)
|
|
||||||
{
|
|
||||||
Operations<boost::forward_traversal_tag>::constraints(i1, i2);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct Operations<boost::random_access_traversal_tag>
|
|
||||||
{
|
{
|
||||||
template <typename Iterator1, typename Iterator2>
|
bool b;
|
||||||
static void constraints(Iterator1 const& i1, Iterator2 const& i2)
|
b = i1 == i2;
|
||||||
{
|
b = i1 != i2;
|
||||||
Operations<boost::bidirectional_traversal_tag>::constraints(i1, i2);
|
|
||||||
|
b = i2 == i1;
|
||||||
i1 < i2;
|
b = i2 != i1;
|
||||||
i1 <= i2;
|
}
|
||||||
i1 > i2;
|
|
||||||
i1 >= i2;
|
template <typename Iterator1, typename Iterator2>
|
||||||
i1 - i2;
|
void interop_rand_access_constraints(Iterator1 const& i1, Iterator2 const& i2,
|
||||||
|
boost::random_access_traversal_tag, boost::random_access_traversal_tag)
|
||||||
i2 < i1;
|
{
|
||||||
i2 <= i1;
|
bool b;
|
||||||
i2 > i1;
|
typename boost::detail::iterator_traits<Iterator2>::difference_type n;
|
||||||
i2 >= i1;
|
b = i1 < i2;
|
||||||
i2 - i1;
|
b = i1 <= i2;
|
||||||
}
|
b = i1 > i2;
|
||||||
};
|
b = i1 >= i2;
|
||||||
|
n = i1 - i2;
|
||||||
|
|
||||||
|
b = i2 < i1;
|
||||||
|
b = i2 <= i1;
|
||||||
|
b = i2 > i1;
|
||||||
|
b = i2 >= i1;
|
||||||
|
n = i2 - i1;
|
||||||
|
}
|
||||||
|
template <typename Iterator1, typename Iterator2>
|
||||||
|
void interop_rand_access_constraints(Iterator1 const& i1, Iterator2 const& i2,
|
||||||
|
boost::single_pass_traversal_tag, boost::single_pass_traversal_tag)
|
||||||
|
{ }
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <typename Iterator, typename ConstIterator>
|
template <typename Iterator, typename ConstIterator>
|
||||||
class InteroperableConcept
|
class InteroperableIteratorConcept
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename boost::detail::pure_traversal_tag<
|
typedef typename boost::detail::pure_traversal_tag<
|
||||||
typename boost::iterator_traversal<
|
typename boost::iterator_traversal<
|
||||||
Iterator
|
Iterator
|
||||||
>::type
|
>::type
|
||||||
>::type traversal_category;
|
>::type traversal_category;
|
||||||
|
|
||||||
typedef typename
|
|
||||||
boost::detail::iterator_traits<Iterator>::difference_type
|
|
||||||
difference_type;
|
|
||||||
|
|
||||||
typedef typename boost::detail::pure_traversal_tag<
|
typedef typename boost::detail::pure_traversal_tag<
|
||||||
typename boost::iterator_traversal<
|
typename boost::iterator_traversal<
|
||||||
ConstIterator
|
ConstIterator
|
||||||
>::type
|
>::type
|
||||||
>::type const_traversal_category;
|
>::type const_traversal_category;
|
||||||
|
|
||||||
typedef typename
|
|
||||||
boost::detail::iterator_traits<ConstIterator>::difference_type
|
|
||||||
const_difference_type;
|
|
||||||
|
|
||||||
void constraints()
|
void constraints()
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT(
|
boost::function_requires< SinglePassIteratorConcept<Iterator> >();
|
||||||
(boost::is_same< difference_type, const_difference_type>::value)
|
boost::function_requires< SinglePassIteratorConcept<ConstIterator> >();
|
||||||
);
|
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(
|
|
||||||
(boost::is_same< traversal_category, const_traversal_category>::value)
|
|
||||||
);
|
|
||||||
|
|
||||||
// ToDo check what the std really requires
|
detail::interop_single_pass_constraints(i, ci);
|
||||||
|
detail::interop_rand_access_constraints(i, ci, traversal_category(), const_traversal_category());
|
||||||
|
|
||||||
// detail::Operations<traversal_category>::constraints(i, ci);
|
ci = i;
|
||||||
|
}
|
||||||
ci = i;
|
Iterator i;
|
||||||
|
ConstIterator ci;
|
||||||
}
|
};
|
||||||
Iterator i;
|
|
||||||
ConstIterator ci;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace boost_concepts
|
} // namespace boost_concepts
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user