Fixes. Remove some Boost.MPL usages. Remove unused includes.

This commit is contained in:
Georqy Guminov
2024-06-23 16:12:29 +03:00
committed by Georgy Guminov
parent 01fd35e9f8
commit b5df827151
19 changed files with 224 additions and 139 deletions

View File

@@ -16,7 +16,6 @@ constant boost_dependencies :
/boost/mpl//boost_mpl /boost/mpl//boost_mpl
/boost/optional//boost_optional /boost/optional//boost_optional
/boost/smart_ptr//boost_smart_ptr /boost/smart_ptr//boost_smart_ptr
/boost/static_assert//boost_static_assert
/boost/type_traits//boost_type_traits /boost/type_traits//boost_type_traits
/boost/utility//boost_utility ; /boost/utility//boost_utility ;

View File

@@ -33,8 +33,6 @@ namespace detail
template <class T> template <class T>
struct is_numeric_impl struct is_numeric_impl
{ {
// For a while, this wasn't true, but we rely on it below. This is a regression assert.
static_assert(std::is_integral<char>::value, "std::is_integral<char> is expected to be true");
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS # ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS

View File

@@ -8,13 +8,13 @@
# include <boost/iterator/iterator_categories.hpp> # include <boost/iterator/iterator_categories.hpp>
# include <boost/mpl/or.hpp> // used in iterator_tag inheritance logic
# include <boost/mpl/and.hpp>
# include <boost/mpl/eval_if.hpp> # include <boost/mpl/eval_if.hpp>
# include <boost/mpl/identity.hpp> # include <boost/mpl/identity.hpp>
# include <type_traits> # include <type_traits>
# include <boost/iterator/detail/type_traits/conjunction.hpp>
# include <boost/iterator/detail/type_traits/disjunction.hpp>
# include <boost/iterator/detail/config_def.hpp> // try to keep this last # include <boost/iterator/detail/config_def.hpp> // try to keep this last
# ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY # ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
@@ -55,13 +55,13 @@ struct input_output_iterator_tag
template <class ValueParam, class Reference> template <class ValueParam, class Reference>
struct iterator_writability_disabled struct iterator_writability_disabled
# ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY // Adding Thomas' logic? # ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY // Adding Thomas' logic?
: mpl::or_< : disjunction<
is_const<Reference> std::is_const<Reference>
, boost::detail::indirect_traits::is_reference_to_const<Reference> , std::integral_constant<bool, boost::detail::indirect_traits::is_reference_to_const<Reference>::value>
, is_const<ValueParam> , std::is_const<ValueParam>
> >
# else # else
: is_const<ValueParam> : std::is_const<ValueParam>
# endif # endif
{}; {};
@@ -77,21 +77,21 @@ struct iterator_writability_disabled
template <class Traversal, class ValueParam, class Reference> template <class Traversal, class ValueParam, class Reference>
struct iterator_facade_default_category struct iterator_facade_default_category
: mpl::eval_if< : mpl::eval_if<
mpl::and_< conjunction<
std::is_reference<Reference> std::is_reference<Reference>
, std::is_convertible<Traversal,forward_traversal_tag> , std::is_convertible<Traversal,forward_traversal_tag>
> >
, mpl::eval_if< , mpl::eval_if<
std::is_convertible<Traversal,random_access_traversal_tag> std::is_convertible<Traversal,random_access_traversal_tag>
, mpl::identity<std::random_access_iterator_tag> , mpl::identity<std::random_access_iterator_tag>
, mpl::if_< , std::conditional<
std::is_convertible<Traversal,bidirectional_traversal_tag> std::is_convertible<Traversal,bidirectional_traversal_tag>::value
, std::bidirectional_iterator_tag , std::bidirectional_iterator_tag
, std::forward_iterator_tag , std::forward_iterator_tag
> >
> >
, typename mpl::eval_if< , typename mpl::eval_if<
mpl::and_< conjunction<
std::is_convertible<Traversal, single_pass_traversal_tag> std::is_convertible<Traversal, single_pass_traversal_tag>
// check for readability // check for readability
@@ -107,7 +107,7 @@ struct iterator_facade_default_category
// True iff T is convertible to an old-style iterator category. // True iff T is convertible to an old-style iterator category.
template <class T> template <class T>
struct is_iterator_category struct is_iterator_category
: mpl::or_< : disjunction<
std::is_convertible<T,std::input_iterator_tag> std::is_convertible<T,std::input_iterator_tag>
, std::is_convertible<T,std::output_iterator_tag> , std::is_convertible<T,std::output_iterator_tag>
> >

View File

@@ -0,0 +1,53 @@
/*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* https://www.boost.org/LICENSE_1_0.txt)
*
* Copyright (c) 2024 Georgiy Guminov
*/
/*!
* \file iterator/detail/type_traits/disjunction.hpp
*
* This header contains definition of \c disjunction type trait.
*/
#ifndef BOOST_ITERATOR_DETAIL_TYPE_TRAITS_DISJUNCTION_HPP_INCLUDED_
#define BOOST_ITERATOR_DETAIL_TYPE_TRAITS_DISJUNCTION_HPP_INCLUDED_
#include <type_traits>
#include <boost/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
#if (defined(__cpp_lib_logical_traits) && (__cpp_lib_logical_traits >= 201510l)) || \
(defined(BOOST_MSSTL_VERSION) && (BOOST_MSSTL_VERSION >= 140) && (_MSC_FULL_VER >= 190023918) && (BOOST_CXX_VERSION >= 201703l))
namespace boost {
namespace iterators {
namespace detail {
using std::disjunction;
} // namespace detail
} // namespace iterator
} // namespace boost
#else
#include <boost/type_traits/disjunction.hpp>
namespace boost {
namespace iterators {
namespace detail {
using boost::disjunction;
} // namespace detail
} // namespace iterator
} // namespace boost
#endif
#endif // BOOST_ITERATOR_DETAIL_TYPE_TRAITS_DISJUNCTION_HPP_INCLUDED_

View File

@@ -0,0 +1,53 @@
/*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* https://www.boost.org/LICENSE_1_0.txt)
*
* Copyright (c) 2024 Georgiy Guminov
*/
/*!
* \file iterator/detail/type_traits/negation.hpp
*
* This header contains definition of \c negation type trait.
*/
#ifndef BOOST_ITERATOR_DETAIL_TYPE_TRAITS_NEGATION_HPP_INCLUDED_
#define BOOST_ITERATOR_DETAIL_TYPE_TRAITS_NEGATION_HPP_INCLUDED_
#include <type_traits>
#include <boost/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
#if (defined(__cpp_lib_logical_traits) && (__cpp_lib_logical_traits >= 201510l)) || \
(defined(BOOST_MSSTL_VERSION) && (BOOST_MSSTL_VERSION >= 140) && (_MSC_FULL_VER >= 190023918) && (BOOST_CXX_VERSION >= 201703l))
namespace boost {
namespace iterators {
namespace detail {
using std::negation;
} // namespace detail
} // namespace iterator
} // namespace boost
#else
#include <boost/type_traits/negation.hpp>
namespace boost {
namespace iterators {
namespace detail {
using boost::negation;
} // namespace detail
} // namespace iterator
} // namespace boost
#endif
#endif // BOOST_ITERATOR_DETAIL_TYPE_TRAITS_NEGATION_HPP_INCLUDED_

View File

@@ -30,11 +30,11 @@ namespace iterators {
filter_iterator<Predicate, Iterator> filter_iterator<Predicate, Iterator>
, Iterator , Iterator
, use_default , use_default
, typename mpl::if_< , typename std::conditional<
std::is_convertible< std::is_convertible<
typename iterator_traversal<Iterator>::type typename iterator_traversal<Iterator>::type
, random_access_traversal_tag , random_access_traversal_tag
> >::value
, bidirectional_traversal_tag , bidirectional_traversal_tag
, use_default , use_default
>::type >::type

View File

@@ -14,7 +14,6 @@
#include <boost/detail/indirect_traits.hpp> #include <boost/detail/indirect_traits.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp> #include <boost/mpl/identity.hpp>
#include <boost/mpl/eval_if.hpp> #include <boost/mpl/eval_if.hpp>
#include <boost/mpl/has_xxx.hpp> #include <boost/mpl/has_xxx.hpp>
@@ -25,7 +24,6 @@
#ifdef BOOST_MPL_CFG_NO_HAS_XXX #ifdef BOOST_MPL_CFG_NO_HAS_XXX
# include <boost/shared_ptr.hpp> # include <boost/shared_ptr.hpp>
# include <boost/scoped_ptr.hpp> # include <boost/scoped_ptr.hpp>
# include <boost/mpl/bool.hpp>
# include <memory> # include <memory>
#endif #endif

View File

@@ -9,9 +9,7 @@
# include <type_traits> # include <type_traits>
# include <boost/mpl/bool.hpp> # include <boost/iterator/detail/type_traits/disjunction.hpp>
# include <boost/mpl/or.hpp>
# include <boost/iterator/detail/config_def.hpp> // must appear last # include <boost/iterator/detail/config_def.hpp> // must appear last
namespace boost { namespace boost {
@@ -33,10 +31,7 @@ namespace iterators {
// //
template <typename A, typename B> template <typename A, typename B>
struct is_interoperable struct is_interoperable
: std::integral_constant< : detail::disjunction<std::is_convertible<A, B>, std::is_convertible<B, A>>
bool
, std::is_convertible< A, B >::value || std::is_convertible< B, A >::value
>
{ {
}; };

View File

@@ -18,6 +18,7 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/type_traits/is_complete.hpp> #include <boost/type_traits/is_complete.hpp>
#include <boost/iterator/detail/type_traits/conjunction.hpp> #include <boost/iterator/detail/type_traits/conjunction.hpp>
#include <boost/iterator/detail/type_traits/negation.hpp>
#if !defined(BOOST_NO_CXX17_ITERATOR_TRAITS) #if !defined(BOOST_NO_CXX17_ITERATOR_TRAITS)
#include <iterator> #include <iterator>
#endif #endif
@@ -69,7 +70,7 @@ template< typename T >
struct is_iterator_impl< T* > : struct is_iterator_impl< T* > :
public conjunction< public conjunction<
boost::is_complete<T>, boost::is_complete<T>,
std::integral_constant<bool, !std::is_function<T>::value> negation< std::is_function< T > >
>::type >::type
{ {
}; };

View File

@@ -7,7 +7,6 @@
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#include <boost/iterator/detail/any_conversion_eater.hpp> #include <boost/iterator/detail/any_conversion_eater.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/lambda_support.hpp> #include <boost/mpl/aux_/lambda_support.hpp>
#include <iterator> #include <iterator>
@@ -84,7 +83,7 @@ namespace detail
struct is_lvalue_iterator_impl<void> struct is_lvalue_iterator_impl<void>
{ {
template <class It> template <class It>
struct rebind : boost::mpl::false_ struct rebind : std::false_type
{}; {};
}; };
@@ -93,7 +92,7 @@ namespace detail
struct is_lvalue_iterator_impl<const void> struct is_lvalue_iterator_impl<const void>
{ {
template <class It> template <class It>
struct rebind : boost::mpl::false_ struct rebind : std::false_type
{}; {};
}; };
@@ -101,7 +100,7 @@ namespace detail
struct is_lvalue_iterator_impl<volatile void> struct is_lvalue_iterator_impl<volatile void>
{ {
template <class It> template <class It>
struct rebind : boost::mpl::false_ struct rebind : std::false_type
{}; {};
}; };
@@ -109,7 +108,7 @@ namespace detail
struct is_lvalue_iterator_impl<const volatile void> struct is_lvalue_iterator_impl<const volatile void>
{ {
template <class It> template <class It>
struct rebind : boost::mpl::false_ struct rebind : std::false_type
{}; {};
}; };
#endif #endif

View File

@@ -4,7 +4,6 @@
#ifndef IS_READABLE_ITERATOR_DWA2003112_HPP #ifndef IS_READABLE_ITERATOR_DWA2003112_HPP
# define IS_READABLE_ITERATOR_DWA2003112_HPP # define IS_READABLE_ITERATOR_DWA2003112_HPP
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/lambda_support.hpp> #include <boost/mpl/aux_/lambda_support.hpp>
#include <boost/iterator/detail/any_conversion_eater.hpp> #include <boost/iterator/detail/any_conversion_eater.hpp>
@@ -54,7 +53,7 @@ namespace detail
struct is_readable_iterator_impl<void> struct is_readable_iterator_impl<void>
{ {
template <class It> template <class It>
struct rebind : boost::mpl::false_ struct rebind : std::false_type
{}; {};
}; };
@@ -63,7 +62,7 @@ namespace detail
struct is_readable_iterator_impl<const void> struct is_readable_iterator_impl<const void>
{ {
template <class It> template <class It>
struct rebind : boost::mpl::false_ struct rebind : std::false_type
{}; {};
}; };
@@ -71,7 +70,7 @@ namespace detail
struct is_readable_iterator_impl<volatile void> struct is_readable_iterator_impl<volatile void>
{ {
template <class It> template <class It>
struct rebind : boost::mpl::false_ struct rebind : std::false_type
{}; {};
}; };
@@ -79,7 +78,7 @@ namespace detail
struct is_readable_iterator_impl<const volatile void> struct is_readable_iterator_impl<const volatile void>
{ {
template <class It> template <class It>
struct rebind : boost::mpl::false_ struct rebind : std::false_type
{}; {};
}; };
#endif #endif

View File

@@ -14,11 +14,11 @@
#include <boost/iterator/iterator_traits.hpp> #include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/iterator_categories.hpp> #include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/detail/facade_iterator_category.hpp> #include <boost/iterator/detail/facade_iterator_category.hpp>
#include <boost/iterator/detail/type_traits/conjunction.hpp>
#include <boost/iterator/detail/type_traits/negation.hpp>
#include <boost/mpl/eval_if.hpp> #include <boost/mpl/eval_if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/always.hpp> #include <boost/mpl/always.hpp>
#include <boost/mpl/apply.hpp> #include <boost/mpl/apply.hpp>
#include <boost/mpl/identity.hpp> #include <boost/mpl/identity.hpp>
@@ -28,6 +28,7 @@
#include <type_traits> #include <type_traits>
#include <memory> #include <memory>
#include <boost/iterator/detail/type_traits/negation.hpp>
#include <boost/iterator/detail/config_def.hpp> // this goes last #include <boost/iterator/detail/config_def.hpp> // this goes last
namespace boost { namespace boost {
@@ -82,7 +83,7 @@ namespace iterators {
> >
struct enable_if_interoperable_and_random_access_traversal : struct enable_if_interoperable_and_random_access_traversal :
public std::enable_if< public std::enable_if<
mpl::and_< detail::conjunction<
is_interoperable< Facade1, Facade2 > is_interoperable< Facade1, Facade2 >
, is_traversal_at_least< typename iterator_category< Facade1 >::type, random_access_traversal_tag > , is_traversal_at_least< typename iterator_category< Facade1 >::type, random_access_traversal_tag >
, is_traversal_at_least< typename iterator_category< Facade2 >::type, random_access_traversal_tag > , is_traversal_at_least< typename iterator_category< Facade2 >::type, random_access_traversal_tag >
@@ -278,7 +279,6 @@ namespace iterators {
}; };
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION # ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class Reference, class Value> template <class Reference, class Value>
struct is_non_proxy_reference_impl struct is_non_proxy_reference_impl
{ {
@@ -299,8 +299,9 @@ namespace iterators {
template <class Reference, class Value> template <class Reference, class Value>
struct is_non_proxy_reference struct is_non_proxy_reference
: mpl::bool_< : std::integral_constant<
is_non_proxy_reference_impl<Reference, Value>::value bool
, is_non_proxy_reference_impl<Reference, Value>::value
> >
{}; {};
# else # else
@@ -332,7 +333,7 @@ namespace iterators {
template <class Iterator, class Value, class Reference, class CategoryOrTraversal> template <class Iterator, class Value, class Reference, class CategoryOrTraversal>
struct postfix_increment_result struct postfix_increment_result
: mpl::eval_if< : mpl::eval_if<
mpl::and_< detail::conjunction<
// A proxy is only needed for readable iterators // A proxy is only needed for readable iterators
std::is_convertible< std::is_convertible<
Reference Reference
@@ -346,7 +347,7 @@ namespace iterators {
// No multipass iterator can have values that disappear // No multipass iterator can have values that disappear
// before positions can be re-visited // before positions can be re-visited
, mpl::not_< , detail::negation<
std::is_convertible< std::is_convertible<
typename iterator_category_to_traversal<CategoryOrTraversal>::type typename iterator_category_to_traversal<CategoryOrTraversal>::type
, forward_traversal_tag , forward_traversal_tag
@@ -430,8 +431,8 @@ namespace iterators {
// proxy, or whether it can simply return a copy of the value_type. // proxy, or whether it can simply return a copy of the value_type.
template <class ValueType, class Reference> template <class ValueType, class Reference>
struct use_operator_brackets_proxy struct use_operator_brackets_proxy
: mpl::not_< : detail::negation<
mpl::and_< detail::conjunction<
// Really we want an is_copy_constructible trait here, // Really we want an is_copy_constructible trait here,
// but is_POD will have to suffice in the meantime. // but is_POD will have to suffice in the meantime.
std::is_standard_layout<ValueType> std::is_standard_layout<ValueType>
@@ -452,13 +453,13 @@ namespace iterators {
}; };
template <class Iterator> template <class Iterator>
operator_brackets_proxy<Iterator> make_operator_brackets_result(Iterator const& iter, mpl::true_) operator_brackets_proxy<Iterator> make_operator_brackets_result(Iterator const& iter, std::true_type)
{ {
return operator_brackets_proxy<Iterator>(iter); return operator_brackets_proxy<Iterator>(iter);
} }
template <class Iterator> template <class Iterator>
typename Iterator::value_type make_operator_brackets_result(Iterator const& iter, mpl::false_) typename Iterator::value_type make_operator_brackets_result(Iterator const& iter, std::false_type)
{ {
return *iter; return *iter;
} }
@@ -763,11 +764,11 @@ namespace iterators {
typename boost::iterators::detail::operator_brackets_result<Derived, Value, reference>::type typename boost::iterators::detail::operator_brackets_result<Derived, Value, reference>::type
operator[](difference_type n) const operator[](difference_type n) const
{ {
typedef boost::iterators::detail::use_operator_brackets_proxy<Value, Reference> use_proxy; const auto use_proxy = boost::iterators::detail::use_operator_brackets_proxy<Value, Reference>::value;
return boost::iterators::detail::make_operator_brackets_result<Derived>( return boost::iterators::detail::make_operator_brackets_result<Derived>(
this->derived() + n this->derived() + n
, use_proxy() , std::integral_constant<bool, use_proxy>{}
); );
} }

View File

@@ -28,37 +28,33 @@
// 04 Feb 2001 Added lvalue test, corrected preconditions // 04 Feb 2001 Added lvalue test, corrected preconditions
// (David Abrahams) // (David Abrahams)
#include <boost/concept_archetype.hpp> // for detail::dummy_constructor
#include <boost/iterator/is_lvalue_iterator.hpp>
#include <boost/iterator/is_readable_iterator.hpp>
#include <boost/pending/iterator_tests.hpp>
#include <iterator> #include <iterator>
#include <type_traits> #include <type_traits>
# include <boost/concept_archetype.hpp> // for detail::dummy_constructor
# include <boost/pending/iterator_tests.hpp>
# include <boost/iterator/is_readable_iterator.hpp>
# include <boost/iterator/is_lvalue_iterator.hpp>
# include <boost/mpl/and.hpp>
# include <boost/iterator/detail/config_def.hpp>
# include <boost/detail/is_incrementable.hpp>
#include <boost/core/lightweight_test.hpp> #include <boost/core/lightweight_test.hpp>
#include <boost/detail/is_incrementable.hpp>
#include <boost/iterator/detail/config_def.hpp>
#include <boost/iterator/detail/type_traits/conjunction.hpp>
namespace boost { namespace boost {
// Do separate tests for *i++ so we can treat, e.g., smart pointers, // Do separate tests for *i++ so we can treat, e.g., smart pointers,
// as readable and/or writable iterators. // as readable and/or writable iterators.
template <class Iterator, class T> template <class Iterator, class T>
void readable_iterator_traversal_test(Iterator i1, T v, mpl::true_) void readable_iterator_traversal_test(Iterator i1, T v, std::true_type) {
{
T v2(*i1++); T v2(*i1++);
BOOST_TEST(v == v2); BOOST_TEST(v == v2);
} }
template <class Iterator, class T> template <class Iterator, class T>
void readable_iterator_traversal_test(const Iterator i1, T v, mpl::false_) void readable_iterator_traversal_test(const Iterator i1, T v, std::false_type) {}
{}
template <class Iterator, class T> template <class Iterator, class T>
void writable_iterator_traversal_test(Iterator i1, T v, mpl::true_) void writable_iterator_traversal_test(Iterator i1, T v, std::true_type) {
{
++i1; // we just wrote into that position ++i1; // we just wrote into that position
*i1++ = v; *i1++ = v;
Iterator x(i1++); Iterator x(i1++);
@@ -66,14 +62,11 @@ void writable_iterator_traversal_test(Iterator i1, T v, mpl::true_)
} }
template <class Iterator, class T> template <class Iterator, class T>
void writable_iterator_traversal_test(const Iterator i1, T v, mpl::false_) void writable_iterator_traversal_test(const Iterator i1, T v, std::false_type) {}
{}
// Preconditions: *i == v // Preconditions: *i == v
template <class Iterator, class T> template <class Iterator, class T>
void readable_iterator_test(const Iterator i1, T v) void readable_iterator_test(const Iterator i1, T v) {
{
Iterator i2(i1); // Copy Constructible Iterator i2(i1); // Copy Constructible
typedef typename std::iterator_traits<Iterator>::reference ref_t; typedef typename std::iterator_traits<Iterator>::reference ref_t;
ref_t r1 = *i1; ref_t r1 = *i1;
@@ -84,32 +77,34 @@ void readable_iterator_test(const Iterator i1, T v)
BOOST_TEST(v2 == v); BOOST_TEST(v2 == v);
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) #if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
readable_iterator_traversal_test(i1, v, detail::is_postfix_incrementable<Iterator>()); readable_iterator_traversal_test(
i1, v,
std::integral_constant<
bool, detail::is_postfix_incrementable<Iterator>::value>{});
// I think we don't really need this as it checks the same things as // I think we don't really need this as it checks the same things as
// the above code. // the above code.
static_assert(is_readable_iterator<Iterator>::value, "Iterator must be readable."); static_assert(is_readable_iterator<Iterator>::value,
"Iterator must be readable.");
#endif #endif
} }
template <class Iterator, class T> template <class Iterator, class T>
void writable_iterator_test(Iterator i, T v, T v2) void writable_iterator_test(Iterator i, T v, T v2) {
{
Iterator i2(i); // Copy Constructible Iterator i2(i); // Copy Constructible
*i2 = v; *i2 = v;
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) #if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
writable_iterator_traversal_test( writable_iterator_traversal_test(
i, v2, mpl::and_< i, v2,
detail::is_incrementable<Iterator> iterators::detail::conjunction<
, detail::is_postfix_incrementable<Iterator> std::integral_constant<bool, detail::is_incrementable<Iterator>::value>,
std::integral_constant<bool, detail::is_postfix_incrementable<Iterator>::value>
>()); >());
#endif #endif
} }
template <class Iterator> template <class Iterator> void swappable_iterator_test(Iterator i, Iterator j) {
void swappable_iterator_test(Iterator i, Iterator j)
{
Iterator i2(i), j2(j); Iterator i2(i), j2(j);
typename std::iterator_traits<Iterator>::value_type bi = *i, bj = *j; typename std::iterator_traits<Iterator>::value_type bi = *i, bj = *j;
iter_swap(i2, j2); iter_swap(i2, j2);
@@ -118,33 +113,31 @@ void swappable_iterator_test(Iterator i, Iterator j)
} }
template <class Iterator, class T> template <class Iterator, class T>
void constant_lvalue_iterator_test(Iterator i, T v1) void constant_lvalue_iterator_test(Iterator i, T v1) {
{
Iterator i2(i); Iterator i2(i);
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;
static_assert( static_assert(std::is_same<const value_type &, reference>::value,
std::is_same<const value_type&, reference>::value, "reference type must be the same as const value_type& for "
"reference type must be the same as const value_type& for constant lvalue iterator." "constant lvalue iterator.");
);
const T &v2 = *i2; const T &v2 = *i2;
BOOST_TEST(v1 == v2); BOOST_TEST(v1 == v2);
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION #ifndef BOOST_NO_LVALUE_RETURN_DETECTION
static_assert(is_lvalue_iterator<Iterator>::value, "Iterator must be lvalue."); static_assert(is_lvalue_iterator<Iterator>::value,
static_assert(!is_non_const_lvalue_iterator<Iterator>::value, "Iterator must be const."); "Iterator must be lvalue.");
static_assert(!is_non_const_lvalue_iterator<Iterator>::value,
"Iterator must be const.");
#endif #endif
} }
template <class Iterator, class T> template <class Iterator, class T>
void non_const_lvalue_iterator_test(Iterator i, T v1, T v2) void non_const_lvalue_iterator_test(Iterator i, T v1, T v2) {
{
Iterator i2(i); Iterator i2(i);
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;
static_assert( static_assert(std::is_same<value_type &, reference>::value,
std::is_same<value_type&, reference>::value, "reference type must be the same as value_type& for "
"reference type must be the same as value_type& for non-constant lvalue iterator." "non-constant lvalue iterator.");
);
T &v3 = *i2; T &v3 = *i2;
BOOST_TEST(v1 == v3); BOOST_TEST(v1 == v3);
@@ -155,14 +148,15 @@ void non_const_lvalue_iterator_test(Iterator i, T v1, T v2)
T &v4 = *i2; T &v4 = *i2;
BOOST_TEST(v2 == v4); BOOST_TEST(v2 == v4);
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION #ifndef BOOST_NO_LVALUE_RETURN_DETECTION
static_assert(is_lvalue_iterator<Iterator>::value, "Iterator must be lvalue."); static_assert(is_lvalue_iterator<Iterator>::value,
static_assert(is_non_const_lvalue_iterator<Iterator>::value, "Iterator must be non-const."); "Iterator must be lvalue.");
static_assert(is_non_const_lvalue_iterator<Iterator>::value,
"Iterator must be non-const.");
#endif #endif
} }
template <class Iterator, class T> template <class Iterator, class T>
void forward_readable_iterator_test(Iterator i, Iterator j, T val1, T val2) void forward_readable_iterator_test(Iterator i, Iterator j, T val1, T val2) {
{
Iterator i2; Iterator i2;
Iterator i3(i); Iterator i3(i);
i2 = i; i2 = i;
@@ -183,8 +177,7 @@ void forward_readable_iterator_test(Iterator i, Iterator j, T val1, T val2)
} }
template <class Iterator, class T> template <class Iterator, class T>
void forward_swappable_iterator_test(Iterator i, Iterator j, T val1, T val2) void forward_swappable_iterator_test(Iterator i, Iterator j, T val1, T val2) {
{
forward_readable_iterator_test(i, j, val1, val2); forward_readable_iterator_test(i, j, val1, val2);
Iterator i2 = i; Iterator i2 = i;
++i2; ++i2;
@@ -194,8 +187,7 @@ void forward_swappable_iterator_test(Iterator i, Iterator j, T val1, T val2)
// bidirectional // bidirectional
// Preconditions: *i == v1, *++i == v2 // Preconditions: *i == v1, *++i == v2
template <class Iterator, class T> template <class Iterator, class T>
void bidirectional_readable_iterator_test(Iterator i, T v1, T v2) void bidirectional_readable_iterator_test(Iterator i, T v1, T v2) {
{
Iterator j(i); Iterator j(i);
++j; ++j;
forward_readable_iterator_test(i, j, v1, v2); forward_readable_iterator_test(i, j, v1, v2);
@@ -224,14 +216,12 @@ void bidirectional_readable_iterator_test(Iterator i, T v1, T v2)
// random access // random access
// Preconditions: [i,i+N) is a valid range // Preconditions: [i,i+N) is a valid range
template <class Iterator, class TrueVals> template <class Iterator, class TrueVals>
void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals) void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals) {
{
bidirectional_readable_iterator_test(i, vals[0], vals[1]); bidirectional_readable_iterator_test(i, vals[0], vals[1]);
const Iterator j = i; const Iterator j = i;
int c; int c;
for (c = 0; c < N-1; ++c) for (c = 0; c < N - 1; ++c) {
{
BOOST_TEST(i == j + c); BOOST_TEST(i == j + c);
BOOST_TEST(*i == vals[c]); BOOST_TEST(*i == vals[c]);
typename std::iterator_traits<Iterator>::value_type x = j[c]; typename std::iterator_traits<Iterator>::value_type x = j[c];
@@ -246,8 +236,7 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals)
} }
Iterator k = j + N - 1; Iterator k = j + N - 1;
for (c = 0; c < N-1; ++c) for (c = 0; c < N - 1; ++c) {
{
BOOST_TEST(i == k - c); BOOST_TEST(i == k - c);
BOOST_TEST(*i == vals[N - 1 - c]); BOOST_TEST(*i == vals[N - 1 - c]);
typename std::iterator_traits<Iterator>::value_type x = j[N - 1 - c]; typename std::iterator_traits<Iterator>::value_type x = j[N - 1 - c];

View File

@@ -8,7 +8,6 @@
#include <boost/core/lightweight_test.hpp> #include <boost/core/lightweight_test.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/assign/list_of.hpp> #include <boost/assign/list_of.hpp>
#include <boost/fusion/include/at.hpp> #include <boost/fusion/include/at.hpp>
#include <boost/iterator/zip_iterator.hpp> #include <boost/iterator/zip_iterator.hpp>

View File

@@ -211,7 +211,7 @@ main()
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) #if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
static_assert( static_assert(
std::is_convertible<Iter1::iterator_category, std::random_access_iterator_tag>::value, std::is_convertible<Iter1::iterator_category, std::random_access_iterator_tag>::value,
"Iter1::iterator_category must be convertible to std::random_access_iterator_tag." "Iterator must have a random access category."
); );
#endif #endif
} }
@@ -225,7 +225,7 @@ main()
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) #if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
static_assert(boost::is_readable_iterator<Iter1>::value, "Iter1 is expected to be readable."); static_assert(boost::is_readable_iterator<Iter1>::value, "Iter1 is expected to be readable.");
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION # ifndef BOOST_NO_LVALUE_RETURN_DETECTION
static_assert(boost::is_lvalue_iterator<Iter1>::value, "Iter1 is expected to be lvalue."); static_assert(boost::is_lvalue_iterator<Iter1>::value, "Iter1 is expected to be lvalue iterator.");
# endif # endif
#endif #endif

View File

@@ -43,6 +43,8 @@ void permutation_test()
const int element_range_size = 10; const int element_range_size = 10;
const int index_size = 7; const int index_size = 7;
static_assert(index_size < element_range_size, "The permutation of some elements is checked.");
element_range_type elements( element_range_size ); element_range_type elements( element_range_size );
for( element_range_type::iterator el_it = elements.begin(); el_it != elements.end(); ++el_it ) for( element_range_type::iterator el_it = elements.begin(); el_it != elements.end(); ++el_it )
{ *el_it = std::distance(elements.begin(), el_it); } { *el_it = std::distance(elements.begin(), el_it); }

View File

@@ -5,7 +5,6 @@
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
#include <boost/range/distance.hpp> #include <boost/range/distance.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/range/iterator_range_core.hpp> #include <boost/range/iterator_range_core.hpp>
#include <boost/iterator/distance.hpp> #include <boost/iterator/distance.hpp>