forked from boostorg/iterator
Fixes. Remove some Boost.MPL usages. Remove unused includes.
This commit is contained in:
committed by
Georgy Guminov
parent
01fd35e9f8
commit
b5df827151
@ -16,7 +16,6 @@ constant boost_dependencies :
|
||||
/boost/mpl//boost_mpl
|
||||
/boost/optional//boost_optional
|
||||
/boost/smart_ptr//boost_smart_ptr
|
||||
/boost/static_assert//boost_static_assert
|
||||
/boost/type_traits//boost_type_traits
|
||||
/boost/utility//boost_utility ;
|
||||
|
||||
|
@ -33,8 +33,6 @@ namespace detail
|
||||
template <class T>
|
||||
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
|
||||
|
||||
|
@ -8,13 +8,13 @@
|
||||
|
||||
# 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/identity.hpp>
|
||||
|
||||
# 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
|
||||
|
||||
# ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
|
||||
@ -55,13 +55,13 @@ struct input_output_iterator_tag
|
||||
template <class ValueParam, class Reference>
|
||||
struct iterator_writability_disabled
|
||||
# ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY // Adding Thomas' logic?
|
||||
: mpl::or_<
|
||||
is_const<Reference>
|
||||
, boost::detail::indirect_traits::is_reference_to_const<Reference>
|
||||
, is_const<ValueParam>
|
||||
: disjunction<
|
||||
std::is_const<Reference>
|
||||
, std::integral_constant<bool, boost::detail::indirect_traits::is_reference_to_const<Reference>::value>
|
||||
, std::is_const<ValueParam>
|
||||
>
|
||||
# else
|
||||
: is_const<ValueParam>
|
||||
: std::is_const<ValueParam>
|
||||
# endif
|
||||
{};
|
||||
|
||||
@ -77,21 +77,21 @@ struct iterator_writability_disabled
|
||||
template <class Traversal, class ValueParam, class Reference>
|
||||
struct iterator_facade_default_category
|
||||
: mpl::eval_if<
|
||||
mpl::and_<
|
||||
conjunction<
|
||||
std::is_reference<Reference>
|
||||
, std::is_convertible<Traversal,forward_traversal_tag>
|
||||
>
|
||||
, mpl::eval_if<
|
||||
std::is_convertible<Traversal,random_access_traversal_tag>
|
||||
, mpl::identity<std::random_access_iterator_tag>
|
||||
, mpl::if_<
|
||||
std::is_convertible<Traversal,bidirectional_traversal_tag>
|
||||
, std::conditional<
|
||||
std::is_convertible<Traversal,bidirectional_traversal_tag>::value
|
||||
, std::bidirectional_iterator_tag
|
||||
, std::forward_iterator_tag
|
||||
>
|
||||
>
|
||||
, typename mpl::eval_if<
|
||||
mpl::and_<
|
||||
conjunction<
|
||||
std::is_convertible<Traversal, single_pass_traversal_tag>
|
||||
|
||||
// check for readability
|
||||
@ -107,7 +107,7 @@ struct iterator_facade_default_category
|
||||
// True iff T is convertible to an old-style iterator category.
|
||||
template <class T>
|
||||
struct is_iterator_category
|
||||
: mpl::or_<
|
||||
: disjunction<
|
||||
std::is_convertible<T,std::input_iterator_tag>
|
||||
, std::is_convertible<T,std::output_iterator_tag>
|
||||
>
|
||||
|
@ -50,4 +50,4 @@ using boost::conjunction;
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BOOST_ITERATOR_DETAIL_TYPE_TRAITS_CONJUNCTION_HPP_INCLUDED_
|
||||
#endif // BOOST_ITERATOR_DETAIL_TYPE_TRAITS_CONJUNCTION_HPP_INCLUDED_
|
||||
|
53
include/boost/iterator/detail/type_traits/disjunction.hpp
Normal file
53
include/boost/iterator/detail/type_traits/disjunction.hpp
Normal 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_
|
53
include/boost/iterator/detail/type_traits/negation.hpp
Normal file
53
include/boost/iterator/detail/type_traits/negation.hpp
Normal 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_
|
@ -30,11 +30,11 @@ namespace iterators {
|
||||
filter_iterator<Predicate, Iterator>
|
||||
, Iterator
|
||||
, use_default
|
||||
, typename mpl::if_<
|
||||
, typename std::conditional<
|
||||
std::is_convertible<
|
||||
typename iterator_traversal<Iterator>::type
|
||||
, random_access_traversal_tag
|
||||
>
|
||||
>::value
|
||||
, bidirectional_traversal_tag
|
||||
, use_default
|
||||
>::type
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include <boost/detail/indirect_traits.hpp>
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
@ -25,7 +24,6 @@
|
||||
#ifdef BOOST_MPL_CFG_NO_HAS_XXX
|
||||
# include <boost/shared_ptr.hpp>
|
||||
# include <boost/scoped_ptr.hpp>
|
||||
# include <boost/mpl/bool.hpp>
|
||||
# include <memory>
|
||||
#endif
|
||||
|
||||
|
@ -9,9 +9,7 @@
|
||||
|
||||
# include <type_traits>
|
||||
|
||||
# include <boost/mpl/bool.hpp>
|
||||
# include <boost/mpl/or.hpp>
|
||||
|
||||
# include <boost/iterator/detail/type_traits/disjunction.hpp>
|
||||
# include <boost/iterator/detail/config_def.hpp> // must appear last
|
||||
|
||||
namespace boost {
|
||||
@ -33,10 +31,7 @@ namespace iterators {
|
||||
//
|
||||
template <typename A, typename B>
|
||||
struct is_interoperable
|
||||
: std::integral_constant<
|
||||
bool
|
||||
, std::is_convertible< A, B >::value || std::is_convertible< B, A >::value
|
||||
>
|
||||
: detail::disjunction<std::is_convertible<A, B>, std::is_convertible<B, A>>
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/is_complete.hpp>
|
||||
#include <boost/iterator/detail/type_traits/conjunction.hpp>
|
||||
#include <boost/iterator/detail/type_traits/negation.hpp>
|
||||
#if !defined(BOOST_NO_CXX17_ITERATOR_TRAITS)
|
||||
#include <iterator>
|
||||
#endif
|
||||
@ -69,7 +70,7 @@ template< typename T >
|
||||
struct is_iterator_impl< T* > :
|
||||
public conjunction<
|
||||
boost::is_complete<T>,
|
||||
std::integral_constant<bool, !std::is_function<T>::value>
|
||||
negation< std::is_function< T > >
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/iterator/detail/any_conversion_eater.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
|
||||
#include <iterator>
|
||||
@ -84,7 +83,7 @@ namespace detail
|
||||
struct is_lvalue_iterator_impl<void>
|
||||
{
|
||||
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>
|
||||
{
|
||||
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>
|
||||
{
|
||||
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>
|
||||
{
|
||||
template <class It>
|
||||
struct rebind : boost::mpl::false_
|
||||
struct rebind : std::false_type
|
||||
{};
|
||||
};
|
||||
#endif
|
||||
|
@ -4,7 +4,6 @@
|
||||
#ifndef 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/iterator/detail/any_conversion_eater.hpp>
|
||||
@ -54,7 +53,7 @@ namespace detail
|
||||
struct is_readable_iterator_impl<void>
|
||||
{
|
||||
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>
|
||||
{
|
||||
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>
|
||||
{
|
||||
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>
|
||||
{
|
||||
template <class It>
|
||||
struct rebind : boost::mpl::false_
|
||||
struct rebind : std::false_type
|
||||
{};
|
||||
};
|
||||
#endif
|
||||
|
@ -14,11 +14,11 @@
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <boost/iterator/iterator_categories.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/or.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
|
||||
#include <boost/mpl/always.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
@ -28,6 +28,7 @@
|
||||
#include <type_traits>
|
||||
#include <memory>
|
||||
|
||||
#include <boost/iterator/detail/type_traits/negation.hpp>
|
||||
#include <boost/iterator/detail/config_def.hpp> // this goes last
|
||||
|
||||
namespace boost {
|
||||
@ -82,7 +83,7 @@ namespace iterators {
|
||||
>
|
||||
struct enable_if_interoperable_and_random_access_traversal :
|
||||
public std::enable_if<
|
||||
mpl::and_<
|
||||
detail::conjunction<
|
||||
is_interoperable< Facade1, Facade2 >
|
||||
, 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 >
|
||||
@ -278,7 +279,6 @@ namespace iterators {
|
||||
};
|
||||
|
||||
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <class Reference, class Value>
|
||||
struct is_non_proxy_reference_impl
|
||||
{
|
||||
@ -299,8 +299,9 @@ namespace iterators {
|
||||
|
||||
template <class Reference, class Value>
|
||||
struct is_non_proxy_reference
|
||||
: mpl::bool_<
|
||||
is_non_proxy_reference_impl<Reference, Value>::value
|
||||
: std::integral_constant<
|
||||
bool
|
||||
, is_non_proxy_reference_impl<Reference, Value>::value
|
||||
>
|
||||
{};
|
||||
# else
|
||||
@ -332,7 +333,7 @@ namespace iterators {
|
||||
template <class Iterator, class Value, class Reference, class CategoryOrTraversal>
|
||||
struct postfix_increment_result
|
||||
: mpl::eval_if<
|
||||
mpl::and_<
|
||||
detail::conjunction<
|
||||
// A proxy is only needed for readable iterators
|
||||
std::is_convertible<
|
||||
Reference
|
||||
@ -346,7 +347,7 @@ namespace iterators {
|
||||
|
||||
// No multipass iterator can have values that disappear
|
||||
// before positions can be re-visited
|
||||
, mpl::not_<
|
||||
, detail::negation<
|
||||
std::is_convertible<
|
||||
typename iterator_category_to_traversal<CategoryOrTraversal>::type
|
||||
, forward_traversal_tag
|
||||
@ -430,8 +431,8 @@ namespace iterators {
|
||||
// proxy, or whether it can simply return a copy of the value_type.
|
||||
template <class ValueType, class Reference>
|
||||
struct use_operator_brackets_proxy
|
||||
: mpl::not_<
|
||||
mpl::and_<
|
||||
: detail::negation<
|
||||
detail::conjunction<
|
||||
// Really we want an is_copy_constructible trait here,
|
||||
// but is_POD will have to suffice in the meantime.
|
||||
std::is_standard_layout<ValueType>
|
||||
@ -452,13 +453,13 @@ namespace iterators {
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@ -763,11 +764,11 @@ namespace iterators {
|
||||
typename boost::iterators::detail::operator_brackets_result<Derived, Value, reference>::type
|
||||
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>(
|
||||
this->derived() + n
|
||||
, use_proxy()
|
||||
, std::integral_constant<bool, use_proxy>{}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef BOOST_NEW_ITERATOR_TESTS_HPP
|
||||
# define BOOST_NEW_ITERATOR_TESTS_HPP
|
||||
#define BOOST_NEW_ITERATOR_TESTS_HPP
|
||||
|
||||
//
|
||||
// Copyright (c) David Abrahams 2001.
|
||||
@ -28,52 +28,45 @@
|
||||
// 04 Feb 2001 Added lvalue test, corrected preconditions
|
||||
// (David Abrahams)
|
||||
|
||||
# include <iterator>
|
||||
# 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/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 <type_traits>
|
||||
|
||||
# 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 {
|
||||
|
||||
|
||||
// Do separate tests for *i++ so we can treat, e.g., smart pointers,
|
||||
// as readable and/or writable iterators.
|
||||
template <class Iterator, class T>
|
||||
void readable_iterator_traversal_test(Iterator i1, T v, mpl::true_)
|
||||
{
|
||||
T v2(*i1++);
|
||||
BOOST_TEST(v == v2);
|
||||
void readable_iterator_traversal_test(Iterator i1, T v, std::true_type) {
|
||||
T v2(*i1++);
|
||||
BOOST_TEST(v == v2);
|
||||
}
|
||||
|
||||
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>
|
||||
void writable_iterator_traversal_test(Iterator i1, T v, mpl::true_)
|
||||
{
|
||||
++i1; // we just wrote into that position
|
||||
*i1++ = v;
|
||||
Iterator x(i1++);
|
||||
(void)x;
|
||||
void writable_iterator_traversal_test(Iterator i1, T v, std::true_type) {
|
||||
++i1; // we just wrote into that position
|
||||
*i1++ = v;
|
||||
Iterator x(i1++);
|
||||
(void)x;
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
typedef typename std::iterator_traits<Iterator>::reference ref_t;
|
||||
ref_t r1 = *i1;
|
||||
@ -83,33 +76,35 @@ void readable_iterator_test(const Iterator i1, T v)
|
||||
BOOST_TEST(v1 == v);
|
||||
BOOST_TEST(v2 == v);
|
||||
|
||||
# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
readable_iterator_traversal_test(i1, v, detail::is_postfix_incrementable<Iterator>());
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
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
|
||||
// the above code.
|
||||
static_assert(is_readable_iterator<Iterator>::value, "Iterator must be readable.");
|
||||
# endif
|
||||
static_assert(is_readable_iterator<Iterator>::value,
|
||||
"Iterator must be readable.");
|
||||
#endif
|
||||
}
|
||||
|
||||
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
|
||||
*i2 = v;
|
||||
|
||||
# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
writable_iterator_traversal_test(
|
||||
i, v2, mpl::and_<
|
||||
detail::is_incrementable<Iterator>
|
||||
, detail::is_postfix_incrementable<Iterator>
|
||||
i, v2,
|
||||
iterators::detail::conjunction<
|
||||
std::integral_constant<bool, detail::is_incrementable<Iterator>::value>,
|
||||
std::integral_constant<bool, detail::is_postfix_incrementable<Iterator>::value>
|
||||
>());
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class Iterator>
|
||||
void swappable_iterator_test(Iterator i, Iterator j)
|
||||
{
|
||||
template <class Iterator> void swappable_iterator_test(Iterator i, Iterator j) {
|
||||
Iterator i2(i), j2(j);
|
||||
typename std::iterator_traits<Iterator>::value_type bi = *i, bj = *j;
|
||||
iter_swap(i2, j2);
|
||||
@ -118,51 +113,50 @@ void swappable_iterator_test(Iterator i, Iterator j)
|
||||
}
|
||||
|
||||
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);
|
||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||
static_assert(
|
||||
std::is_same<const value_type&, reference>::value,
|
||||
"reference type must be the same as const value_type& for constant lvalue iterator."
|
||||
);
|
||||
const T& v2 = *i2;
|
||||
static_assert(std::is_same<const value_type &, reference>::value,
|
||||
"reference type must be the same as const value_type& for "
|
||||
"constant lvalue iterator.");
|
||||
const T &v2 = *i2;
|
||||
BOOST_TEST(v1 == v2);
|
||||
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
||||
static_assert(is_lvalue_iterator<Iterator>::value, "Iterator must be lvalue.");
|
||||
static_assert(!is_non_const_lvalue_iterator<Iterator>::value, "Iterator must be const.");
|
||||
# endif
|
||||
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
||||
static_assert(is_lvalue_iterator<Iterator>::value,
|
||||
"Iterator must be lvalue.");
|
||||
static_assert(!is_non_const_lvalue_iterator<Iterator>::value,
|
||||
"Iterator must be const.");
|
||||
#endif
|
||||
}
|
||||
|
||||
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);
|
||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||
static_assert(
|
||||
std::is_same<value_type&, reference>::value,
|
||||
"reference type must be the same as value_type& for non-constant lvalue iterator."
|
||||
);
|
||||
T& v3 = *i2;
|
||||
static_assert(std::is_same<value_type &, reference>::value,
|
||||
"reference type must be the same as value_type& for "
|
||||
"non-constant lvalue iterator.");
|
||||
T &v3 = *i2;
|
||||
BOOST_TEST(v1 == v3);
|
||||
|
||||
// A non-const lvalue iterator is not necessarily writable, but we
|
||||
// are assuming the value_type is assignable here
|
||||
*i = v2;
|
||||
|
||||
T& v4 = *i2;
|
||||
T &v4 = *i2;
|
||||
BOOST_TEST(v2 == v4);
|
||||
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
||||
static_assert(is_lvalue_iterator<Iterator>::value, "Iterator must be lvalue.");
|
||||
static_assert(is_non_const_lvalue_iterator<Iterator>::value, "Iterator must be non-const.");
|
||||
# endif
|
||||
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
||||
static_assert(is_lvalue_iterator<Iterator>::value,
|
||||
"Iterator must be lvalue.");
|
||||
static_assert(is_non_const_lvalue_iterator<Iterator>::value,
|
||||
"Iterator must be non-const.");
|
||||
#endif
|
||||
}
|
||||
|
||||
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 i3(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>
|
||||
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);
|
||||
Iterator i2 = i;
|
||||
++i2;
|
||||
@ -194,8 +187,7 @@ void forward_swappable_iterator_test(Iterator i, Iterator j, T val1, T val2)
|
||||
// bidirectional
|
||||
// Preconditions: *i == v1, *++i == v2
|
||||
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);
|
||||
++j;
|
||||
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
|
||||
// Preconditions: [i,i+N) is a valid range
|
||||
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]);
|
||||
const Iterator j = i;
|
||||
int c;
|
||||
|
||||
for (c = 0; c < N-1; ++c)
|
||||
{
|
||||
for (c = 0; c < N - 1; ++c) {
|
||||
BOOST_TEST(i == j + c);
|
||||
BOOST_TEST(*i == vals[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;
|
||||
for (c = 0; c < N-1; ++c)
|
||||
{
|
||||
for (c = 0; c < N - 1; ++c) {
|
||||
BOOST_TEST(i == k - c);
|
||||
BOOST_TEST(*i == vals[N - 1 - c]);
|
||||
typename std::iterator_traits<Iterator>::value_type x = j[N - 1 - c];
|
||||
@ -264,6 +253,6 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals)
|
||||
|
||||
} // namespace boost
|
||||
|
||||
# include <boost/iterator/detail/config_undef.hpp>
|
||||
#include <boost/iterator/detail/config_undef.hpp>
|
||||
|
||||
#endif // BOOST_NEW_ITERATOR_TESTS_HPP
|
||||
|
@ -142,8 +142,8 @@ template <bool is_pointer> struct lvalue_test
|
||||
# endif
|
||||
static_assert(std::is_reference<reference>::value, "reference must be a reference type.");
|
||||
static_assert(
|
||||
std::is_same<reference, value_type&>::value || std::is_same<reference, const value_type&>::value,
|
||||
"reference must either be a reference to value_type or constant reference to value_type."
|
||||
std::is_same<reference, value_type&>::value || std::is_same<reference, const value_type&>::value,
|
||||
"reference must either be a reference to value_type or constant reference to value_type."
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/fusion/include/at.hpp>
|
||||
#include <boost/iterator/zip_iterator.hpp>
|
||||
|
@ -210,8 +210,8 @@ main()
|
||||
test = static_assert_same<Iter1::difference_type, std::ptrdiff_t>::value;
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
static_assert(
|
||||
std::is_convertible<Iter1::iterator_category, std::random_access_iterator_tag>::value,
|
||||
"Iter1::iterator_category must be convertible to std::random_access_iterator_tag."
|
||||
std::is_convertible<Iter1::iterator_category, std::random_access_iterator_tag>::value,
|
||||
"Iterator must have a random access category."
|
||||
);
|
||||
#endif
|
||||
}
|
||||
@ -225,7 +225,7 @@ main()
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
static_assert(boost::is_readable_iterator<Iter1>::value, "Iter1 is expected to be readable.");
|
||||
# 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
|
||||
|
||||
|
@ -43,6 +43,8 @@ void permutation_test()
|
||||
const int element_range_size = 10;
|
||||
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 );
|
||||
for( element_range_type::iterator el_it = elements.begin(); el_it != elements.end(); ++el_it )
|
||||
{ *el_it = std::distance(elements.begin(), el_it); }
|
||||
|
@ -5,7 +5,6 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/range/distance.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/iterator/distance.hpp>
|
||||
|
||||
|
Reference in New Issue
Block a user