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