Mostly remove pre-CXX11 workarounds.

С++03 support was deprecated in 1.85 and now can be removed. This PR clears
many of workarounds, which are no longer needed now.

* Remove unused workaround macros (many of).
* Remove BOOST_STATIC_ASSERT usages.
* Minimize Boost::type_traits dependency (in favour of STL's type_traits).

Closes https://github.com/boostorg/iterator/pull/82.

Squashed commit of the following:

commit 741a627b736ba81fe0054e5bf373141b04a8a597
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sat Jan 25 12:13:05 2025 +0300

    Replace testers with standard metafunctions.

commit bf4cce611454713f1c8e5f46a2c3e599c548656d
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sat Jan 25 11:51:32 2025 +0300

    Refactor is_lvalue_iterator.hpp.

commit 8d080c6c58726269cf55aedd64aa239f7d098fc7
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sat Jan 25 10:27:32 2025 +0300

    Remove more workarounds.

commit 5a4ba24d361ac0676d2cce95fdff22824ecdc287
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sun Jan 19 16:38:30 2025 +0300

    Fixes.

commit fdfafce2b9a71b1d85cbc697983652788f1c4bb7
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sat Oct 26 15:06:43 2024 +0300

    Remove BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
    Correct static_assert messages.
    Fix messages & replace is_standard_layout with is_copy_constructible.

commit c69ac1408af2fe5a105b288644367bbb6e0bc30d
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sat Oct 26 14:48:51 2024 +0300

    Correct static_assert messages.

commit b5df827151a6d752168a59fa8c20c9ffd3766c0b
Author: Georqy Guminov <gogagum@gmail.com>
Date:   Sun Jun 23 16:12:29 2024 +0300

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

commit 01fd35e9f87d43f4bb46ed525a0e8eec46cba44a
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Wed Jun 12 17:14:21 2024 +0300

    abstract conjunction.

commit c02def8acf68e0829082761d26955320974e5078
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Wed Jun 12 16:35:43 2024 +0300

    return addressof & conjunction.

commit 3b3d1625752cbe8c9ec62662e594a1af1fd9a458
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Wed Jun 12 16:30:44 2024 +0300

    Make macro more readable.

commit 4ab19e045fc535dc80228062d11bb6584ccd17ff
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Wed Jun 12 15:56:49 2024 +0300

    Add static_assert messages.

commit 82b5c44cd34435d63af5cdbc7fcc1b07b39394de
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Wed Jun 12 14:12:10 2024 +0300

    Return is iterator CXX17 test.

commit 2d58d65462e837430a0990c2a414d5c397e9fa31
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Tue Jun 11 14:04:17 2024 +0300

    Omitted.

commit a0d04d9491de818df990188436e04afc3ddba3ad
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Tue Jun 11 14:00:35 2024 +0300

    Replace move with static_cast

commit 4a49b8a1a2d44d2da728dd064fe810ca86d8d1fd
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Mon Jun 10 21:38:53 2024 +0300

    Return BOOST_NOEXCEPT

commit 054c013bba75c42710537a819de91d6abfe25658
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Sun Jun 9 15:20:41 2024 +0300

    CXX11
This commit is contained in:
Georgy Guminov 2025-01-26 15:17:36 +03:00 committed by Andrey Semashev
parent 53101ffab9
commit f9effffb6d
56 changed files with 683 additions and 1181 deletions

View File

@ -24,7 +24,6 @@ target_link_libraries(boost_iterator
Boost::mpl Boost::mpl
Boost::optional Boost::optional
Boost::smart_ptr Boost::smart_ptr
Boost::static_assert
Boost::type_traits Boost::type_traits
Boost::utility Boost::utility
) )

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

@ -6,11 +6,7 @@
# include "node.hpp" # include "node.hpp"
# include <boost/iterator/iterator_facade.hpp> # include <boost/iterator/iterator_facade.hpp>
# include <type_traits>
# ifndef BOOST_NO_SFINAE
# include <boost/type_traits/is_convertible.hpp>
# include <boost/utility/enable_if.hpp>
# endif
template <class Value> template <class Value>
class node_iter class node_iter
@ -33,21 +29,13 @@ class node_iter
template <class OtherValue> template <class OtherValue>
node_iter( node_iter(
node_iter<OtherValue> const& other node_iter<OtherValue> const& other
# ifndef BOOST_NO_SFINAE , typename std::enable_if<
, typename boost::enable_if< std::is_convertible<OtherValue*,Value*>::value
boost::is_convertible<OtherValue*,Value*>
, enabler , enabler
>::type = enabler() >::type = enabler()
# endif
) )
: m_node(other.m_node) {} : m_node(other.m_node) {}
# if !BOOST_WORKAROUND(__GNUC__, == 2)
private: // GCC2 can't grant friendship to template member functions
friend class boost::iterator_core_access;
# endif
template <class OtherValue> template <class OtherValue>
bool equal(node_iter<OtherValue> const& other) const bool equal(node_iter<OtherValue> const& other) const
{ {

View File

@ -6,11 +6,7 @@
# include "node.hpp" # include "node.hpp"
# include <boost/iterator/iterator_adaptor.hpp> # include <boost/iterator/iterator_adaptor.hpp>
# include <type_traits>
# ifndef BOOST_NO_SFINAE
# include <boost/type_traits/is_convertible.hpp>
# include <boost/utility/enable_if.hpp>
# endif
template <class Value> template <class Value>
class node_iter class node_iter
@ -38,12 +34,10 @@ class node_iter
template <class OtherValue> template <class OtherValue>
node_iter( node_iter(
node_iter<OtherValue> const& other node_iter<OtherValue> const& other
# ifndef BOOST_NO_SFINAE , typename std::enable_if<
, typename boost::enable_if< std::is_convertible<OtherValue*,Value*>::value
boost::is_convertible<OtherValue*,Value*>
, enabler , enabler
>::type = enabler() >::type = enabler()
# endif
) )
: super_t(other.base()) {} : super_t(other.base()) {}

View File

@ -68,7 +68,7 @@ struct generator_iterator_generator
template <class Generator> template <class Generator>
inline generator_iterator<Generator> inline generator_iterator<Generator>
make_generator_iterator(Generator & gen) make_generator_iterator(Generator& gen)
{ {
typedef generator_iterator<Generator> result_t; typedef generator_iterator<Generator> result_t;
return result_t(&gen); return result_t(&gen);

View File

@ -13,7 +13,6 @@
# include <boost/detail/is_incrementable.hpp> # include <boost/detail/is_incrementable.hpp>
# include <boost/iterator/iterator_traits.hpp> # include <boost/iterator/iterator_traits.hpp>
# include <boost/type_traits/remove_cv.hpp>
# include <boost/mpl/eval_if.hpp> # include <boost/mpl/eval_if.hpp>
# include <boost/pointee.hpp> # include <boost/pointee.hpp>

View File

@ -29,12 +29,6 @@ namespace iterators {
} }
} }
#if BOOST_WORKAROUND(BOOST_GCC_VERSION, >= 40600)
// type-limits warning issued below when n is an unsigned integral
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits"
#endif
template <typename BidirectionalIterator, typename Distance> template <typename BidirectionalIterator, typename Distance>
inline BOOST_CXX14_CONSTEXPR void inline BOOST_CXX14_CONSTEXPR void
advance_impl( advance_impl(
@ -57,10 +51,6 @@ namespace iterators {
} }
} }
#if BOOST_WORKAROUND(BOOST_GCC_VERSION, >= 40600)
#pragma GCC diagnostic pop
#endif
template <typename RandomAccessIterator, typename Distance> template <typename RandomAccessIterator, typename Distance>
inline BOOST_CXX14_CONSTEXPR void inline BOOST_CXX14_CONSTEXPR void
advance_impl( advance_impl(

View File

@ -5,19 +5,14 @@
#ifndef COUNTING_ITERATOR_DWA200348_HPP #ifndef COUNTING_ITERATOR_DWA200348_HPP
# define COUNTING_ITERATOR_DWA200348_HPP # define COUNTING_ITERATOR_DWA200348_HPP
# include <type_traits>
# include <boost/config.hpp> # include <boost/config.hpp>
# include <boost/static_assert.hpp> # include <boost/detail/workaround.hpp>
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS # ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
# include <limits> # include <limits>
# elif !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
# include <boost/type_traits/is_convertible.hpp>
# else
# include <boost/type_traits/is_arithmetic.hpp>
# endif # endif
# include <boost/type_traits/is_integral.hpp>
# include <boost/type_traits/type_identity.hpp> # include <boost/type_traits/type_identity.hpp>
# include <boost/type_traits/conditional.hpp>
# include <boost/type_traits/integral_constant.hpp>
# include <boost/detail/numeric_traits.hpp> # include <boost/detail/numeric_traits.hpp>
# include <boost/iterator/iterator_adaptor.hpp> # include <boost/iterator/iterator_adaptor.hpp>
@ -38,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.
BOOST_STATIC_ASSERT(::boost::is_integral<char>::value);
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS # ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
@ -50,11 +43,11 @@ namespace detail
# if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551)) # if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
BOOST_STATIC_CONSTANT( BOOST_STATIC_CONSTANT(
bool, value = ( bool, value = (
boost::is_convertible<int,T>::value std::is_convertible<int,T>::value
&& boost::is_convertible<T,int>::value && std::is_convertible<T,int>::value
)); ));
# else # else
BOOST_STATIC_CONSTANT(bool, value = ::boost::is_arithmetic<T>::value); BOOST_STATIC_CONSTANT(bool, value = std::is_arithmetic<T>::value);
# endif # endif
# endif # endif
@ -62,7 +55,7 @@ namespace detail
template <class T> template <class T>
struct is_numeric struct is_numeric
: boost::integral_constant<bool, ::boost::iterators::detail::is_numeric_impl<T>::value> : std::integral_constant<bool, ::boost::iterators::detail::is_numeric_impl<T>::value>
{}; {};
# if defined(BOOST_HAS_LONG_LONG) # if defined(BOOST_HAS_LONG_LONG)
@ -116,7 +109,7 @@ namespace detail
{ {
typedef typename detail::ia_dflt_help< typedef typename detail::ia_dflt_help<
CategoryOrTraversal CategoryOrTraversal
, typename boost::conditional< , typename std::conditional<
is_numeric<Incrementable>::value is_numeric<Incrementable>::value
, boost::type_identity<random_access_traversal_tag> , boost::type_identity<random_access_traversal_tag>
, iterator_traversal<Incrementable> , iterator_traversal<Incrementable>
@ -125,7 +118,7 @@ namespace detail
typedef typename detail::ia_dflt_help< typedef typename detail::ia_dflt_help<
Difference Difference
, typename boost::conditional< , typename std::conditional<
is_numeric<Incrementable>::value is_numeric<Incrementable>::value
, numeric_difference<Incrementable> , numeric_difference<Incrementable>
, iterator_difference<Incrementable> , iterator_difference<Incrementable>
@ -225,7 +218,7 @@ class counting_iterator
difference_type difference_type
distance_to(counting_iterator<OtherIncrementable, CategoryOrTraversal, Difference> const& y) const distance_to(counting_iterator<OtherIncrementable, CategoryOrTraversal, Difference> const& y) const
{ {
typedef typename boost::conditional< typedef typename std::conditional<
detail::is_numeric<Incrementable>::value detail::is_numeric<Incrementable>::value
, detail::number_distance<difference_type, Incrementable, OtherIncrementable> , detail::number_distance<difference_type, Incrementable, OtherIncrementable>
, detail::iterator_distance<difference_type, Incrementable, OtherIncrementable> , detail::iterator_distance<difference_type, Incrementable, OtherIncrementable>

View File

@ -1,21 +0,0 @@
// Copyright David Abrahams 2003. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef ANY_CONVERSION_EATER_DWA20031117_HPP
# define ANY_CONVERSION_EATER_DWA20031117_HPP
namespace boost {
namespace iterators {
namespace detail {
// This type can be used in traits to "eat" up the one user-defined
// implicit conversion allowed.
struct any_conversion_eater
{
template <class T>
any_conversion_eater(T const&);
};
}}} // namespace boost::iterators::detail
#endif // ANY_CONVERSION_EATER_DWA20031117_HPP

View File

@ -26,8 +26,7 @@
// libs/iterator/test/constant_iterator_arrow.cpp fails to compile // libs/iterator/test/constant_iterator_arrow.cpp fails to compile
// because the operator-> return is improperly deduced as a non-const // because the operator-> return is improperly deduced as a non-const
// pointer. // pointer.
#if 1 || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ #if 1
|| BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x531))
// Recall that in general, compilers without partial specialization // Recall that in general, compilers without partial specialization
// can't strip constness. Consider counting_iterator, which normally // can't strip constness. Consider counting_iterator, which normally
@ -46,83 +45,4 @@
#endif #endif
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x5A0)) \
|| (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) && defined(_MSC_VER)) \
|| BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) \
|| BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
# define BOOST_NO_LVALUE_RETURN_DETECTION
# if 0 // test code
struct v {};
typedef char (&no)[3];
template <class T>
no foo(T const&, ...);
template <class T>
char foo(T&, int);
struct value_iterator
{
v operator*() const;
};
template <class T>
struct lvalue_deref_helper
{
static T& x;
enum { value = (sizeof(foo(*x,0)) == 1) };
};
int z2[(lvalue_deref_helper<v*>::value == 1) ? 1 : -1];
int z[(lvalue_deref_helper<value_iterator>::value) == 1 ? -1 : 1 ];
# endif
#endif
#if BOOST_WORKAROUND(__MWERKS__, <=0x2407)
# define BOOST_NO_IS_CONVERTIBLE // "is_convertible doesn't work for simple types"
#endif
#if BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, < 4) && !defined(__EDG_VERSION__) \
|| BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
# define BOOST_NO_IS_CONVERTIBLE_TEMPLATE // The following program fails to compile:
# if 0 // test code
#include <boost/type_traits/is_convertible.hpp>
template <class T>
struct foo
{
foo(T);
template <class U>
foo(foo<U> const& other) : p(other.p) { }
T p;
};
bool x = boost::is_convertible<foo<int const*>, foo<int*> >::value;
# endif
#endif
#if !defined(BOOST_MSVC) && (defined(BOOST_NO_SFINAE) || defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_IS_CONVERTIBLE_TEMPLATE))
# define BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
#endif
# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
// GCC-2.95 (obsolete) eagerly instantiates templated constructors and conversion
// operators in convertibility checks, causing premature errors.
//
// Borland's problems are harder to diagnose due to lack of an
// instantiation stack backtrace. They may be due in part to the fact
// that it drops cv-qualification willy-nilly in templates.
# define BOOST_NO_ONE_WAY_ITERATOR_INTEROP
# endif
// no include guard; multiple inclusion intended // no include guard; multiple inclusion intended

View File

@ -11,11 +11,7 @@
// 23/02/03 thw // 23/02/03 thw
// //
#undef BOOST_NO_IS_CONVERTIBLE #undef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
#undef BOOST_NO_IS_CONVERTIBLE_TEMPLATE
#undef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
#undef BOOST_NO_LVALUE_RETURN_DETECTION
#undef BOOST_NO_ONE_WAY_ITERATOR_INTEROP
#ifdef BOOST_ITERATOR_CONFIG_DEF #ifdef BOOST_ITERATOR_CONFIG_DEF
# undef BOOST_ITERATOR_CONFIG_DEF # undef BOOST_ITERATOR_CONFIG_DEF

View File

@ -1,83 +0,0 @@
// (C) Copyright David Abrahams 2002.
// (C) Copyright Jeremy Siek 2002.
// (C) Copyright Thomas Witt 2002.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ENABLE_IF_23022003THW_HPP
#define BOOST_ENABLE_IF_23022003THW_HPP
#include <boost/config.hpp>
#include <boost/iterator/detail/config_def.hpp>
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_IS_CONVERTIBLE)
#include <boost/type_traits/type_identity.hpp>
#endif
//
// Boost iterators uses its own enable_if cause we need
// special semantics for deficient compilers.
// 23/02/03 thw
//
namespace boost
{
namespace iterators
{
//
// Base machinery for all kinds of enable if
//
template<bool>
struct enabled
{
template<typename T>
struct base
{
typedef T type;
};
};
//
// For compilers that don't support "Substitution Failure Is Not An Error"
// enable_if falls back to always enabled. See comments
// on operator implementation for consequences.
//
template<>
struct enabled<false>
{
template<typename T>
struct base
{
#ifdef BOOST_NO_SFINAE
typedef T type;
// This way to do it would give a nice error message containing
// invalid overload, but has the big disadvantage that
// there is no reference to user code in the error message.
//
// struct invalid_overload;
// typedef invalid_overload type;
//
#endif
};
};
template <class Cond,
class Return>
struct enable_if
# if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_IS_CONVERTIBLE)
: enabled<(Cond::value)>::template base<Return>
# else
: boost::type_identity<Return>
# endif
{
};
} // namespace iterators
} // namespace boost
#include <boost/iterator/detail/config_undef.hpp>
#endif // BOOST_ENABLE_IF_23022003THW_HPP

View File

@ -8,19 +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/if.hpp>
# include <boost/mpl/eval_if.hpp> # include <boost/mpl/eval_if.hpp>
# include <boost/mpl/identity.hpp> # include <boost/mpl/identity.hpp>
# include <boost/static_assert.hpp> # include <type_traits>
# include <boost/type_traits/is_same.hpp>
# include <boost/type_traits/is_const.hpp>
# include <boost/type_traits/is_reference.hpp>
# include <boost/type_traits/is_convertible.hpp>
# 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
@ -61,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
{}; {};
@ -83,25 +77,25 @@ 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_< detail::conjunction<
is_reference<Reference> std::is_reference<Reference>
, is_convertible<Traversal,forward_traversal_tag> , std::is_convertible<Traversal,forward_traversal_tag>
> >
, mpl::eval_if< , mpl::eval_if<
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<
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< , mpl::eval_if<
mpl::and_< detail::conjunction<
is_convertible<Traversal, single_pass_traversal_tag> std::is_convertible<Traversal, single_pass_traversal_tag>
// check for readability // check for readability
, is_convertible<Reference, ValueParam> , std::is_convertible<Reference, ValueParam>
> >
, mpl::identity<std::input_iterator_tag> , mpl::identity<std::input_iterator_tag>
, mpl::identity<Traversal> , mpl::identity<Traversal>
@ -113,16 +107,16 @@ 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<
is_convertible<T,std::input_iterator_tag> std::is_convertible<T,std::input_iterator_tag>
, is_convertible<T,std::output_iterator_tag> , std::is_convertible<T,std::output_iterator_tag>
> >
{ {
}; };
template <class T> template <class T>
struct is_iterator_traversal struct is_iterator_traversal
: is_convertible<T,incrementable_traversal_tag> : std::is_convertible<T,incrementable_traversal_tag>
{}; {};
// //
@ -138,18 +132,18 @@ struct iterator_category_with_traversal
// Make sure this isn't used to build any categories where // Make sure this isn't used to build any categories where
// convertibility to Traversal is redundant. Should just use the // convertibility to Traversal is redundant. Should just use the
// Category element in that case. // Category element in that case.
BOOST_STATIC_ASSERT(( static_assert(
!is_convertible< !std::is_convertible<
typename iterator_category_to_traversal<Category>::type typename iterator_category_to_traversal<Category>::type
, Traversal , Traversal
>::value)); >::value,
"Category transformed to corresponding traversal must be convertible to Traversal."
);
BOOST_STATIC_ASSERT(is_iterator_category<Category>::value); static_assert(is_iterator_category<Category>::value, "Category must be an STL iterator category.");
BOOST_STATIC_ASSERT(!is_iterator_category<Traversal>::value); static_assert(!is_iterator_category<Traversal>::value, "Traversal must not be an STL iterator category.");
BOOST_STATIC_ASSERT(!is_iterator_traversal<Category>::value); static_assert(!is_iterator_traversal<Category>::value, "Category must not be a traversal tag.");
# if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) static_assert(is_iterator_traversal<Traversal>::value, "Traversal must be a traversal tag.");
BOOST_STATIC_ASSERT(is_iterator_traversal<Traversal>::value);
# endif
}; };
// Computes an iterator_category tag whose traversal is Traversal and // Computes an iterator_category tag whose traversal is Traversal and
@ -157,17 +151,17 @@ struct iterator_category_with_traversal
template <class Traversal, class ValueParam, class Reference> template <class Traversal, class ValueParam, class Reference>
struct facade_iterator_category_impl struct facade_iterator_category_impl
{ {
BOOST_STATIC_ASSERT(!is_iterator_category<Traversal>::value); static_assert(!is_iterator_category<Traversal>::value, "Traversal must not be an STL iterator category.");
typedef typename iterator_facade_default_category< typedef typename iterator_facade_default_category<
Traversal,ValueParam,Reference Traversal,ValueParam,Reference
>::type category; >::type category;
typedef typename mpl::if_< typedef typename std::conditional<
is_same< std::is_same<
Traversal Traversal
, typename iterator_category_to_traversal<category>::type , typename iterator_category_to_traversal<category>::type
> >::value
, category , category
, iterator_category_with_traversal<category,Traversal> , iterator_category_with_traversal<category,Traversal>
>::type type; >::type type;

View File

@ -1,19 +0,0 @@
// Copyright David Abrahams 2003. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef MINIMUM_CATEGORY_DWA20031119_HPP
# define MINIMUM_CATEGORY_DWA20031119_HPP
# include <boost/iterator/minimum_category.hpp>
namespace boost {
// This import below (as well as the whole header) is for backward compatibility
// with boost/token_iterator.hpp. It should be removed as soon as that header is fixed.
namespace detail {
using iterators::minimum_category;
} // namespace detail
} // namespace boost
#endif // MINIMUM_CATEGORY_DWA20031119_HPP

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/conjunction.hpp
*
* This header contains definition of \c conjunction type trait.
*/
#ifndef BOOST_ITERATOR_DETAIL_TYPE_TRAITS_CONJUNCTION_HPP_INCLUDED_
#define BOOST_ITERATOR_DETAIL_TYPE_TRAITS_CONJUNCTION_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::conjunction;
} // namespace detail
} // namespace iterator
} // namespace boost
#else
#include <boost/type_traits/conjunction.hpp>
namespace boost {
namespace iterators {
namespace detail {
using boost::conjunction;
} // namespace detail
} // namespace iterator
} // namespace boost
#endif
#endif // BOOST_ITERATOR_DETAIL_TYPE_TRAITS_CONJUNCTION_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/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

@ -7,19 +7,11 @@
#ifndef BOOST_FILTER_ITERATOR_23022003THW_HPP #ifndef BOOST_FILTER_ITERATOR_23022003THW_HPP
#define BOOST_FILTER_ITERATOR_23022003THW_HPP #define BOOST_FILTER_ITERATOR_23022003THW_HPP
#include <type_traits>
#include <boost/iterator/iterator_adaptor.hpp> #include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_categories.hpp> #include <boost/iterator/iterator_categories.hpp>
#include <boost/core/use_default.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/static_assert.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
#define BOOST_ITERATOR_DETAIL_MOVE(_type, _value) static_cast< _type&& >(_value)
#else
#define BOOST_ITERATOR_DETAIL_MOVE(_type, _value) _value
#endif
namespace boost { namespace boost {
namespace iterators { namespace iterators {
@ -36,11 +28,11 @@ namespace iterators {
filter_iterator<Predicate, Iterator> filter_iterator<Predicate, Iterator>
, Iterator , Iterator
, use_default , use_default
, typename mpl::if_< , typename std::conditional<
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
@ -62,21 +54,17 @@ namespace iterators {
filter_iterator() { } filter_iterator() { }
filter_iterator(Predicate f, Iterator x, Iterator end_ = Iterator()) filter_iterator(Predicate f, Iterator x, Iterator end_ = Iterator())
: super_t(BOOST_ITERATOR_DETAIL_MOVE(Iterator, x)), m_predicate(BOOST_ITERATOR_DETAIL_MOVE(Predicate, f)), m_end(BOOST_ITERATOR_DETAIL_MOVE(Iterator, end_)) : super_t(static_cast<Iterator&&>(x)), m_predicate(static_cast<Predicate&&>(f)), m_end(static_cast<Iterator&&>(end_))
{ {
satisfy_predicate(); satisfy_predicate();
} }
filter_iterator(Iterator x, Iterator end_ = Iterator()) filter_iterator(Iterator x, Iterator end_ = Iterator())
: super_t(BOOST_ITERATOR_DETAIL_MOVE(Iterator, x)), m_predicate(), m_end(BOOST_ITERATOR_DETAIL_MOVE(Iterator, end_)) : super_t(static_cast<Iterator&&>(x)), m_predicate(), m_end(static_cast<Iterator&&>(end_))
{ {
// Pro8 is a little too aggressive about instantiating the
// body of this function.
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
// Don't allow use of this constructor if Predicate is a // Don't allow use of this constructor if Predicate is a
// function pointer type, since it will be 0. // function pointer type, since it will be 0.
BOOST_STATIC_ASSERT(is_class<Predicate>::value); static_assert(std::is_class<Predicate>::value, "Predicate must be a class.");
#endif
satisfy_predicate(); satisfy_predicate();
} }
@ -119,19 +107,19 @@ namespace iterators {
inline filter_iterator<Predicate,Iterator> inline filter_iterator<Predicate,Iterator>
make_filter_iterator(Predicate f, Iterator x, Iterator end = Iterator()) make_filter_iterator(Predicate f, Iterator x, Iterator end = Iterator())
{ {
return filter_iterator<Predicate,Iterator>(BOOST_ITERATOR_DETAIL_MOVE(Predicate, f), BOOST_ITERATOR_DETAIL_MOVE(Iterator, x), BOOST_ITERATOR_DETAIL_MOVE(Iterator, end)); return filter_iterator<Predicate,Iterator>(static_cast<Predicate&&>(f), static_cast<Iterator&&>(x), static_cast<Iterator&&>(end));
} }
template <class Predicate, class Iterator> template <class Predicate, class Iterator>
inline filter_iterator<Predicate,Iterator> inline filter_iterator<Predicate,Iterator>
make_filter_iterator( make_filter_iterator(
typename iterators::enable_if< typename std::enable_if<
is_class<Predicate> std::is_class<Predicate>::value
, Iterator , Iterator
>::type x >::type x
, Iterator end = Iterator()) , Iterator end = Iterator())
{ {
return filter_iterator<Predicate,Iterator>(BOOST_ITERATOR_DETAIL_MOVE(Iterator, x), BOOST_ITERATOR_DETAIL_MOVE(Iterator, end)); return filter_iterator<Predicate,Iterator>(static_cast<Iterator&&>(x), static_cast<Iterator&&>(end));
} }
} // namespace iterators } // namespace iterators
@ -141,6 +129,4 @@ using iterators::make_filter_iterator;
} // namespace boost } // namespace boost
#undef BOOST_ITERATOR_DETAIL_MOVE
#endif // BOOST_FILTER_ITERATOR_23022003THW_HPP #endif // BOOST_FILTER_ITERATOR_23022003THW_HPP

View File

@ -9,10 +9,10 @@
#ifndef BOOST_FUNCTION_INPUT_ITERATOR #ifndef BOOST_FUNCTION_INPUT_ITERATOR
#define BOOST_FUNCTION_INPUT_ITERATOR #define BOOST_FUNCTION_INPUT_ITERATOR
#include <type_traits>
#include <memory>
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/core/addressof.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/function_types/is_function_pointer.hpp> #include <boost/function_types/is_function_pointer.hpp>
#include <boost/function_types/result_type.hpp> #include <boost/function_types/result_type.hpp>
#include <boost/iterator/iterator_facade.hpp> #include <boost/iterator/iterator_facade.hpp>
@ -20,10 +20,6 @@
#include <boost/optional/optional.hpp> #include <boost/optional/optional.hpp>
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
#ifdef BOOST_RESULT_OF_USE_TR1
#include <boost/type_traits/is_function.hpp>
#endif
namespace boost { namespace boost {
namespace iterators { namespace iterators {
@ -41,7 +37,7 @@ namespace iterators {
{ {
typedef typename result_of< typedef typename result_of<
#ifdef BOOST_RESULT_OF_USE_TR1 #ifdef BOOST_RESULT_OF_USE_TR1
typename boost::conditional<is_function<F>::value, F&, F>::type() typename std::conditional<std::is_function<F>::value, F&, F>::type()
#else #else
F&() F&()
#endif #endif
@ -54,13 +50,13 @@ namespace iterators {
iterators::function_input_iterator<Function, Input>, iterators::function_input_iterator<Function, Input>,
typename result_of_nullary_lvalue_call<Function>::type, typename result_of_nullary_lvalue_call<Function>::type,
single_pass_traversal_tag, single_pass_traversal_tag,
typename result_of_nullary_lvalue_call<Function>::type const & typename result_of_nullary_lvalue_call<Function>::type const&
> >
{ {
public: public:
function_object_input_iterator() {} function_object_input_iterator() {}
function_object_input_iterator(Function & f_, Input state_ = Input()) function_object_input_iterator(Function& f_, Input state_ = Input())
: f(boost::addressof(f_)), state(state_) {} : f(std::addressof(f_)), state(state_) {}
void increment() { void increment() {
if (value) if (value)
@ -70,14 +66,14 @@ namespace iterators {
++state; ++state;
} }
typename result_of_nullary_lvalue_call<Function>::type const & typename result_of_nullary_lvalue_call<Function>::type const&
dereference() const { dereference() const {
if (!value) if (!value)
value = (*f)(); value = (*f)();
return value.get(); return value.get();
} }
bool equal(function_object_input_iterator const & other) const { bool equal(function_object_input_iterator const& other) const {
return f == other.f && state == other.state; return f == other.f && state == other.state;
} }
@ -93,12 +89,12 @@ namespace iterators {
iterators::function_input_iterator<Function, Input>, iterators::function_input_iterator<Function, Input>,
typename function_types::result_type<Function>::type, typename function_types::result_type<Function>::type,
single_pass_traversal_tag, single_pass_traversal_tag,
typename function_types::result_type<Function>::type const & typename function_types::result_type<Function>::type const&
> >
{ {
public: public:
function_pointer_input_iterator() {} function_pointer_input_iterator() {}
function_pointer_input_iterator(Function &f_, Input state_ = Input()) function_pointer_input_iterator(Function& f_, Input state_ = Input())
: f(f_), state(state_) {} : f(f_), state(state_) {}
void increment() { void increment() {
@ -109,14 +105,14 @@ namespace iterators {
++state; ++state;
} }
typename function_types::result_type<Function>::type const & typename function_types::result_type<Function>::type const&
dereference() const { dereference() const {
if (!value) if (!value)
value = (*f)(); value = (*f)();
return value.get(); return value.get();
} }
bool equal(function_pointer_input_iterator const & other) const { bool equal(function_pointer_input_iterator const& other) const {
return f == other.f && state == other.state; return f == other.f && state == other.state;
} }
@ -130,42 +126,42 @@ namespace iterators {
template <class Function, class Input> template <class Function, class Input>
class function_input_iterator : class function_input_iterator :
public boost::conditional< public std::conditional<
function_types::is_function_pointer<Function>::value, function_types::is_function_pointer<Function>::value,
impl::function_pointer_input_iterator<Function,Input>, impl::function_pointer_input_iterator<Function,Input>,
impl::function_object_input_iterator<Function,Input> impl::function_object_input_iterator<Function,Input>
>::type >::type
{ {
typedef typename boost::conditional< typedef typename std::conditional<
function_types::is_function_pointer<Function>::value, function_types::is_function_pointer<Function>::value,
impl::function_pointer_input_iterator<Function,Input>, impl::function_pointer_input_iterator<Function,Input>,
impl::function_object_input_iterator<Function,Input> impl::function_object_input_iterator<Function,Input>
>::type base_type; >::type base_type;
public: public:
function_input_iterator(Function & f, Input i) function_input_iterator(Function& f, Input i)
: base_type(f, i) {} : base_type(f, i) {}
}; };
template <class Function, class Input> template <class Function, class Input>
inline function_input_iterator<Function, Input> inline function_input_iterator<Function, Input>
make_function_input_iterator(Function & f, Input state) { make_function_input_iterator(Function& f, Input state) {
typedef function_input_iterator<Function, Input> result_t; typedef function_input_iterator<Function, Input> result_t;
return result_t(f, state); return result_t(f, state);
} }
template <class Function, class Input> template <class Function, class Input>
inline function_input_iterator<Function*, Input> inline function_input_iterator<Function*, Input>
make_function_input_iterator(Function * f, Input state) { make_function_input_iterator(Function* f, Input state) {
typedef function_input_iterator<Function*, Input> result_t; typedef function_input_iterator<Function*, Input> result_t;
return result_t(f, state); return result_t(f, state);
} }
struct infinite struct infinite
{ {
infinite & operator++() { return *this; } infinite& operator++() { return *this; }
infinite & operator++(int) { return *this; } infinite& operator++(int) { return *this; }
bool operator==(infinite &) const { return false; }; bool operator==(infinite&) const { return false; };
bool operator==(infinite const &) const { return false; }; bool operator==(infinite const&) const { return false; };
}; };
} // namespace iterators } // namespace iterators

View File

@ -13,13 +13,9 @@
#include <cstddef> #include <cstddef>
#include <iterator> #include <iterator>
#include <type_traits>
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_cv.hpp>
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
#include <boost/type_traits/remove_reference.hpp>
#endif
namespace boost { namespace boost {
namespace iterators { namespace iterators {
@ -33,25 +29,15 @@ namespace iterators {
public: public:
explicit output_proxy(UnaryFunction& f) BOOST_NOEXCEPT : m_f(f) { } explicit output_proxy(UnaryFunction& f) BOOST_NOEXCEPT : m_f(f) { }
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
template <class T> template <class T>
typename boost::disable_if_c<
boost::is_same< typename boost::remove_cv< T >::type, output_proxy >::value, typename std::enable_if<
output_proxy const& !std::is_same< typename std::remove_cv< typename std::remove_reference< T >::type >::type, output_proxy >::value,
>::type operator=(const T& value) const {
m_f(value);
return *this;
}
#else
template <class T>
typename boost::disable_if_c<
boost::is_same< typename boost::remove_cv< typename boost::remove_reference< T >::type >::type, output_proxy >::value,
output_proxy const& output_proxy const&
>::type operator=(T&& value) const { >::type operator=(T&& value) const {
m_f(static_cast< T&& >(value)); m_f(static_cast< T&& >(value));
return *this; return *this;
} }
#endif
BOOST_DEFAULTED_FUNCTION(output_proxy(output_proxy const& that), BOOST_NOEXCEPT : m_f(that.m_f) {}) BOOST_DEFAULTED_FUNCTION(output_proxy(output_proxy const& that), BOOST_NOEXCEPT : m_f(that.m_f) {})
BOOST_DELETED_FUNCTION(output_proxy& operator=(output_proxy const&)) BOOST_DELETED_FUNCTION(output_proxy& operator=(output_proxy const&))

View File

@ -14,25 +14,12 @@
#include <boost/detail/indirect_traits.hpp> #include <boost/detail/indirect_traits.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/add_reference.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/not.hpp>
#include <boost/mpl/has_xxx.hpp> #include <boost/mpl/has_xxx.hpp>
#include <iterator> #include <iterator>
#include <type_traits>
#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
#include <boost/iterator/detail/config_def.hpp> // must be last #include
namespace boost { namespace boost {
namespace iterators { namespace iterators {
@ -57,9 +44,9 @@ namespace iterators {
, typename ia_dflt_help< , typename ia_dflt_help<
Reference Reference
, mpl::eval_if< , mpl::eval_if<
is_same<Value,use_default> std::is_same<Value,use_default>
, indirect_reference<dereferenceable> , indirect_reference<dereferenceable>
, add_reference<Value> , std::add_lvalue_reference<Value>
> >
>::type >::type
, Difference , Difference
@ -111,11 +98,7 @@ namespace iterators {
private: private:
typename super_t::reference dereference() const typename super_t::reference dereference() const
{ {
# if BOOST_WORKAROUND(BOOST_BORLANDC, < 0x5A0 )
return const_cast<super_t::reference>(**this->base());
# else
return **this->base(); return **this->base();
# endif
} }
}; };
@ -140,6 +123,4 @@ using iterators::make_indirect_iterator;
} // namespace boost } // namespace boost
#include <boost/iterator/detail/config_undef.hpp>
#endif // BOOST_INDIRECT_ITERATOR_23022003THW_HPP #endif // BOOST_INDIRECT_ITERATOR_23022003THW_HPP

View File

@ -7,12 +7,7 @@
#ifndef BOOST_INTEROPERABLE_23022003THW_HPP #ifndef BOOST_INTEROPERABLE_23022003THW_HPP
# define BOOST_INTEROPERABLE_23022003THW_HPP # define BOOST_INTEROPERABLE_23022003THW_HPP
# include <boost/mpl/bool.hpp> # include <boost/iterator/detail/type_traits/disjunction.hpp>
# include <boost/mpl/or.hpp>
# include <boost/type_traits/is_convertible.hpp>
# include <boost/iterator/detail/config_def.hpp> // must appear last
namespace boost { namespace boost {
namespace iterators { namespace iterators {
@ -33,13 +28,7 @@ namespace iterators {
// //
template <typename A, typename B> template <typename A, typename B>
struct is_interoperable struct is_interoperable
# ifdef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY : detail::disjunction<std::is_convertible<A, B>, std::is_convertible<B, A>>
: mpl::true_
# else
: mpl::or_<
is_convertible< A, B >
, is_convertible< B, A > >
# endif
{ {
}; };
@ -49,6 +38,4 @@ using iterators::is_interoperable;
} // namespace boost } // namespace boost
# include <boost/iterator/detail/config_undef.hpp>
#endif // BOOST_INTEROPERABLE_23022003THW_HPP #endif // BOOST_INTEROPERABLE_23022003THW_HPP

View File

@ -16,15 +16,15 @@
#include <cstddef> #include <cstddef>
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/negation.hpp>
#include <boost/type_traits/conjunction.hpp>
#include <boost/type_traits/is_complete.hpp> #include <boost/type_traits/is_complete.hpp>
#include <boost/type_traits/is_function.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
#include <type_traits>
#ifdef BOOST_HAS_PRAGMA_ONCE #ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once #pragma once
#endif #endif
@ -59,56 +59,56 @@ no_type check(...);
template< typename T > template< typename T >
struct is_iterator_impl : struct is_iterator_impl :
public boost::integral_constant< public std::integral_constant<
bool, bool,
sizeof(has_iterator_category_detail::check< T >(0)) == sizeof(has_iterator_category_detail::yes_type) sizeof(has_iterator_category_detail::check<T>(0)) == sizeof(has_iterator_category_detail::yes_type)
> >
{ {
}; };
template< typename T > template< typename T >
struct is_iterator_impl< T* > : struct is_iterator_impl< T* > :
public boost::conjunction< public conjunction<
boost::is_complete< T >, boost::is_complete<T>,
boost::negation< boost::is_function< T > > negation< std::is_function< T > >
>::type >::type
{ {
}; };
template< typename T, typename U > template< typename T, typename U >
struct is_iterator_impl< T U::* > : struct is_iterator_impl< T U::* > :
public boost::false_type public std::false_type
{ {
}; };
template< typename T > template< typename T >
struct is_iterator_impl< T& > : struct is_iterator_impl<T&> :
public boost::false_type public std::false_type
{ {
}; };
template< typename T, std::size_t N > template< typename T, std::size_t N >
struct is_iterator_impl< T[N] > : struct is_iterator_impl< T[N] > :
public boost::false_type public std::false_type
{ {
}; };
#if !defined(BOOST_TT_HAS_WORKING_IS_COMPLETE) #if !defined(BOOST_TT_HAS_WORKING_IS_COMPLETE)
template< typename T > template< typename T >
struct is_iterator_impl< T[] > : struct is_iterator_impl< T[] > :
public boost::false_type public std::false_type
{ {
}; };
template< > template< >
struct is_iterator_impl< void > : struct is_iterator_impl< void > :
public boost::false_type public std::false_type
{ {
}; };
template< > template< >
struct is_iterator_impl< void* > : struct is_iterator_impl< void* > :
public boost::false_type public std::false_type
{ {
}; };
#endif // !defined(BOOST_TT_HAS_WORKING_IS_COMPLETE) #endif // !defined(BOOST_TT_HAS_WORKING_IS_COMPLETE)

View File

@ -6,18 +6,11 @@
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#include <boost/type_traits/add_lvalue_reference.hpp> #include <boost/iterator/detail/type_traits/conjunction.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>
#include <type_traits>
// should be the last #includes
#include <boost/type_traits/integral_constant.hpp>
#include <boost/iterator/detail/config_def.hpp>
#ifndef BOOST_NO_IS_CONVERTIBLE
namespace boost { namespace boost {
@ -25,61 +18,23 @@ namespace iterators {
namespace detail namespace detail
{ {
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION
// Calling lvalue_preserver( <expression>, 0 ) returns a reference
// to the expression's result if <expression> is an lvalue, or
// not_an_lvalue() otherwise.
struct not_an_lvalue {};
template <class T>
T& lvalue_preserver(T&, int);
template <class U>
not_an_lvalue lvalue_preserver(U const&, ...);
# define BOOST_LVALUE_PRESERVER(expr) detail::lvalue_preserver(expr,0)
#else
# define BOOST_LVALUE_PRESERVER(expr) expr
#endif
// Guts of is_lvalue_iterator. Value is the iterator's value_type // Guts of is_lvalue_iterator. Value is the iterator's value_type
// and the result is computed in the nested rebind template. // and the result is computed in the nested rebind template.
template <class Value> template <class Value>
struct is_lvalue_iterator_impl struct is_lvalue_iterator_impl
{ {
// Eat implicit conversions so we don't report true for things template <class It>
// convertible to Value const& using DerefT = decltype(*std::declval<It&>());
struct conversion_eater
{
conversion_eater(typename add_lvalue_reference<Value>::type);
};
static char tester(conversion_eater, int);
static char (& tester(any_conversion_eater, ...) )[2];
template <class It> template <class It>
struct rebind struct rebind : detail::conjunction<
std::is_convertible<DerefT<It>, typename std::add_lvalue_reference<Value>::type>
, std::is_lvalue_reference<DerefT<It>>
>::type
{ {
static It& x;
BOOST_STATIC_CONSTANT(
bool
, value = (
sizeof(
is_lvalue_iterator_impl<Value>::tester(
BOOST_LVALUE_PRESERVER(*x), 0
)
) == 1
)
);
}; };
}; };
#undef BOOST_LVALUE_PRESERVER
// //
// void specializations to handle std input and output iterators // void specializations to handle std input and output iterators
// //
@ -87,7 +42,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
{}; {};
}; };
@ -96,7 +51,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
{}; {};
}; };
@ -104,7 +59,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
{}; {};
}; };
@ -112,7 +67,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
@ -137,14 +92,14 @@ namespace detail
} // namespace detail } // namespace detail
template< typename T > struct is_lvalue_iterator template< typename T > struct is_lvalue_iterator
: public ::boost::integral_constant<bool,::boost::iterators::detail::is_readable_lvalue_iterator_impl<T>::value> : public std::integral_constant<bool,::boost::iterators::detail::is_readable_lvalue_iterator_impl<T>::value>
{ {
public: public:
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_lvalue_iterator,(T)) BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_lvalue_iterator,(T))
}; };
template< typename T > struct is_non_const_lvalue_iterator template< typename T > struct is_non_const_lvalue_iterator
: public ::boost::integral_constant<bool,::boost::iterators::detail::is_non_const_lvalue_iterator_impl<T>::value> : public std::integral_constant<bool,::boost::iterators::detail::is_non_const_lvalue_iterator_impl<T>::value>
{ {
public: public:
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_non_const_lvalue_iterator,(T)) BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_non_const_lvalue_iterator,(T))
@ -157,8 +112,4 @@ using iterators::is_non_const_lvalue_iterator;
} // namespace boost } // namespace boost
#endif
#include <boost/iterator/detail/config_undef.hpp>
#endif // IS_LVALUE_ITERATOR_DWA2003112_HPP #endif // IS_LVALUE_ITERATOR_DWA2003112_HPP

View File

@ -4,19 +4,10 @@
#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/type_traits/add_lvalue_reference.hpp>
#include <boost/iterator/detail/any_conversion_eater.hpp>
#include <iterator> #include <iterator>
#include <type_traits>
// should be the last #include
#include <boost/type_traits/integral_constant.hpp>
#include <boost/iterator/detail/config_def.hpp>
#ifndef BOOST_NO_IS_CONVERTIBLE
namespace boost { namespace boost {
@ -29,26 +20,13 @@ namespace detail
template <class Value> template <class Value>
struct is_readable_iterator_impl struct is_readable_iterator_impl
{ {
static char tester(typename add_lvalue_reference<Value>::type, int);
static char (& tester(any_conversion_eater, ...) )[2];
template <class It> template <class It>
struct rebind struct rebind : std::is_convertible<
{ decltype(*std::declval<It&>())
static It& x; , typename std::add_lvalue_reference<Value>::type
>
BOOST_STATIC_CONSTANT( {};
bool
, value = (
sizeof(
is_readable_iterator_impl<Value>::tester(*x, 1)
) == 1
)
);
}; };
};
#undef BOOST_READABLE_PRESERVER
// //
// void specializations to handle std input and output iterators // void specializations to handle std input and output iterators
@ -57,7 +35,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
{}; {};
}; };
@ -66,7 +44,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
{}; {};
}; };
@ -74,7 +52,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
{}; {};
}; };
@ -82,7 +60,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
@ -100,7 +78,7 @@ namespace detail
} // namespace detail } // namespace detail
template< typename T > struct is_readable_iterator template< typename T > struct is_readable_iterator
: public ::boost::integral_constant<bool,::boost::iterators::detail::is_readable_iterator_impl2<T>::value> : public std::integral_constant<bool,::boost::iterators::detail::is_readable_iterator_impl2<T>::value>
{ {
public: public:
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_readable_iterator,(T)) BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_readable_iterator,(T))
@ -112,8 +90,4 @@ using iterators::is_readable_iterator;
} // namespace boost } // namespace boost
#endif
#include <boost/iterator/detail/config_undef.hpp>
#endif // IS_READABLE_ITERATOR_DWA2003112_HPP #endif // IS_READABLE_ITERATOR_DWA2003112_HPP

View File

@ -7,30 +7,16 @@
#ifndef BOOST_ITERATOR_ADAPTOR_23022003THW_HPP #ifndef BOOST_ITERATOR_ADAPTOR_23022003THW_HPP
#define BOOST_ITERATOR_ADAPTOR_23022003THW_HPP #define BOOST_ITERATOR_ADAPTOR_23022003THW_HPP
#include <boost/static_assert.hpp>
#include <boost/core/use_default.hpp> #include <boost/core/use_default.hpp>
#include <type_traits>
#include <boost/iterator/iterator_categories.hpp> #include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_facade.hpp> #include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/detail/enable_if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/or.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_convertible.hpp>
#ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
# include <boost/type_traits/remove_reference.hpp>
#endif
#include <boost/type_traits/add_reference.hpp>
#include <boost/iterator/detail/config_def.hpp>
#include <boost/iterator/iterator_traits.hpp> #include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/detail/config_def.hpp>
namespace boost { namespace boost {
namespace iterators { namespace iterators {
@ -41,13 +27,6 @@ namespace iterators {
} // namespace iterators } // namespace iterators
// the incompleteness of use_default causes massive problems for
// is_convertible (naturally). This workaround is fortunately not
// needed for vc6/vc7.
template<class To>
struct is_convertible<use_default,To>
: mpl::false_ {};
namespace iterators { namespace iterators {
namespace detail namespace detail
@ -102,41 +81,14 @@ namespace iterators {
// false positives for user/library defined iterator types. See comments // false positives for user/library defined iterator types. See comments
// on operator implementation for consequences. // on operator implementation for consequences.
// //
# if defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_SFINAE)
template <class From, class To>
struct enable_if_convertible
{
typedef boost::iterators::detail::enable_type type;
};
# elif BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(13102292))
// For some reason vc7.1 needs us to "cut off" instantiation
// of is_convertible in a few cases.
template<typename From, typename To> template<typename From, typename To>
struct enable_if_convertible struct enable_if_convertible
: iterators::enable_if< : std::enable_if<
mpl::or_< std::is_convertible<From, To>::value
is_same<From,To>
, is_convertible<From, To>
>
, boost::iterators::detail::enable_type , boost::iterators::detail::enable_type
> >
{}; {};
# else
template<typename From, typename To>
struct enable_if_convertible
: iterators::enable_if<
is_convertible<From, To>
, boost::iterators::detail::enable_type
>
{};
# endif
// //
// Default template argument handling for iterator_adaptor // Default template argument handling for iterator_adaptor
// //
@ -147,7 +99,7 @@ namespace iterators {
template <class T, class DefaultNullaryFn> template <class T, class DefaultNullaryFn>
struct ia_dflt_help struct ia_dflt_help
: mpl::eval_if< : mpl::eval_if<
is_same<T, use_default> std::is_same<T, use_default>
, DefaultNullaryFn , DefaultNullaryFn
, mpl::identity<T> , mpl::identity<T>
> >
@ -173,9 +125,9 @@ namespace iterators {
, typename boost::iterators::detail::ia_dflt_help< , typename boost::iterators::detail::ia_dflt_help<
Value Value
, mpl::eval_if< , mpl::eval_if<
is_same<Reference,use_default> std::is_same<Reference,use_default>
, iterator_value<Base> , iterator_value<Base>
, remove_reference<Reference> , std::remove_reference<Reference>
> >
>::type >::type
# else # else
@ -192,9 +144,9 @@ namespace iterators {
, typename boost::iterators::detail::ia_dflt_help< , typename boost::iterators::detail::ia_dflt_help<
Reference Reference
, mpl::eval_if< , mpl::eval_if<
is_same<Value,use_default> std::is_same<Value,use_default>
, iterator_reference<Base> , iterator_reference<Base>
, add_reference<Value> , std::add_lvalue_reference<Value>
> >
>::type >::type
@ -204,13 +156,6 @@ namespace iterators {
> >
type; type;
}; };
// workaround for aC++ CR JAGaf33512
template <class Tr1, class Tr2>
inline void iterator_adaptor_assert_traversal ()
{
BOOST_STATIC_ASSERT((is_convertible<Tr1, Tr2>::value));
}
} }
// //
@ -220,7 +165,7 @@ namespace iterators {
// versions of iterator_adaptor The idea is that when the user needs // versions of iterator_adaptor The idea is that when the user needs
// to fiddle with the reference type it is highly likely that the // to fiddle with the reference type it is highly likely that the
// iterator category has to be adjusted as well. Any of the // iterator category has to be adjusted as well. Any of the
// following four template arguments may be ommitted or explicitly // following four template arguments may be omitted or explicitly
// replaced by use_default. // replaced by use_default.
// //
// Value - if supplied, the value_type of the resulting iterator, unless // Value - if supplied, the value_type of the resulting iterator, unless
@ -260,7 +205,7 @@ namespace iterators {
public: public:
iterator_adaptor() {} iterator_adaptor() {}
explicit iterator_adaptor(Base const &iter) explicit iterator_adaptor(Base const& iter)
: m_iterator(iter) : m_iterator(iter)
{ {
} }
@ -309,12 +254,12 @@ namespace iterators {
typename super_t::iterator_category typename super_t::iterator_category
>::type my_traversal; >::type my_traversal;
# define BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(cat) \
boost::iterators::detail::iterator_adaptor_assert_traversal<my_traversal, cat>();
void advance(typename super_t::difference_type n) void advance(typename super_t::difference_type n)
{ {
BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(random_access_traversal_tag) static_assert(
std::is_convertible<my_traversal, random_access_traversal_tag>::value,
"Iterator must support random access traversal."
);
m_iterator += n; m_iterator += n;
} }
@ -322,7 +267,10 @@ namespace iterators {
void decrement() void decrement()
{ {
BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(bidirectional_traversal_tag) static_assert(
std::is_convertible<my_traversal, bidirectional_traversal_tag>::value,
"Iterator must support bidirectional traversal."
);
--m_iterator; --m_iterator;
} }
@ -332,7 +280,10 @@ namespace iterators {
typename super_t::difference_type distance_to( typename super_t::difference_type distance_to(
iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const
{ {
BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(random_access_traversal_tag) static_assert(
std::is_convertible<my_traversal, random_access_traversal_tag>::value,
"Super iterator must support random access traversal."
);
// Maybe readd with same_distance // Maybe readd with same_distance
// BOOST_STATIC_ASSERT( // BOOST_STATIC_ASSERT(
// (detail::same_category_and_difference<Derived,OtherDerived>::value) // (detail::same_category_and_difference<Derived,OtherDerived>::value)
@ -340,8 +291,6 @@ namespace iterators {
return y.base() - m_iterator; return y.base() - m_iterator;
} }
# undef BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL
private: // data members private: // data members
Base m_iterator; Base m_iterator;
}; };

View File

@ -8,23 +8,17 @@
#include <boost/iterator/iterator_categories.hpp> #include <boost/iterator/iterator_categories.hpp>
#include <boost/operators.hpp> #include <boost/operators.hpp>
#include <boost/static_assert.hpp>
#include <boost/iterator/detail/facade_iterator_category.hpp> #include <boost/iterator/detail/facade_iterator_category.hpp>
#include <boost/type_traits/is_const.hpp> #include <type_traits>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/concept_archetype.hpp> #include <boost/concept_archetype.hpp>
#include <boost/mpl/bitand.hpp> #include <boost/mpl/bitand.hpp>
#include <boost/mpl/int.hpp> #include <boost/mpl/int.hpp>
#include <boost/mpl/equal_to.hpp> #include <boost/mpl/equal_to.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/eval_if.hpp> #include <boost/mpl/eval_if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/identity.hpp> #include <boost/mpl/identity.hpp>
#include <cstddef> #include <cstddef>
@ -119,18 +113,18 @@ namespace detail
template <class Value, class AccessCategory, class TraversalCategory> template <class Value, class AccessCategory, class TraversalCategory>
struct operator_brackets struct operator_brackets
: mpl::eval_if< : mpl::eval_if<
is_convertible<TraversalCategory, random_access_traversal_tag> std::is_convertible<TraversalCategory, random_access_traversal_tag>
, mpl::eval_if< , mpl::eval_if<
archetypes::has_access< archetypes::has_access<
AccessCategory AccessCategory
, archetypes::writable_iterator_t , archetypes::writable_iterator_t
> >
, mpl::identity<writable_operator_brackets<Value> > , mpl::identity<writable_operator_brackets<Value> >
, mpl::if_< , std::conditional<
archetypes::has_access< archetypes::has_access<
AccessCategory AccessCategory
, archetypes::readable_iterator_t , archetypes::readable_iterator_t
> >::value
, readable_operator_brackets<Value> , readable_operator_brackets<Value>
, no_operator_brackets , no_operator_brackets
> >
@ -280,8 +274,8 @@ namespace detail
template <class Value> template <class Value>
struct convertible_type struct convertible_type
: mpl::if_< is_const<Value>, : std::conditional< std::is_const<Value>::value,
typename remove_const<Value>::type, typename std::remove_const<Value>::type,
bogus_type > bogus_type >
{}; {};
@ -312,7 +306,7 @@ struct iterator_access_archetype_impl<
template <class Value> template <class Value>
struct archetype struct archetype
{ {
typedef typename remove_cv<Value>::type value_type; typedef typename std::remove_cv<Value>::type value_type;
typedef Value reference; typedef Value reference;
typedef Value* pointer; typedef Value* pointer;
@ -330,7 +324,7 @@ struct iterator_access_archetype_impl<
template <class Value> template <class Value>
struct archetype struct archetype
{ {
BOOST_STATIC_ASSERT(!is_const<Value>::value); static_assert(!std::is_const<Value>::value, "Value type must not be const.");
typedef void value_type; typedef void value_type;
typedef void reference; typedef void reference;
typedef void pointer; typedef void pointer;
@ -381,7 +375,7 @@ struct iterator_access_archetype_impl<archetypes::writable_lvalue_iterator_t>
Value, archetypes::readable_lvalue_iterator_t Value, archetypes::readable_lvalue_iterator_t
> >
{ {
BOOST_STATIC_ASSERT((!is_const<Value>::value)); static_assert(!std::is_const<Value>::value, "Value type must not be const.");
}; };
}; };
@ -392,7 +386,7 @@ struct iterator_archetype;
template <class Value, class AccessCategory, class TraversalCategory> template <class Value, class AccessCategory, class TraversalCategory>
struct traversal_archetype_base struct traversal_archetype_base
: detail::operator_brackets< : detail::operator_brackets<
typename remove_cv<Value>::type typename std::remove_cv<Value>::type
, AccessCategory , AccessCategory
, TraversalCategory , TraversalCategory
> >
@ -419,8 +413,8 @@ namespace detail
archetypes::has_access< archetypes::has_access<
AccessCategory, archetypes::writable_iterator_t AccessCategory, archetypes::writable_iterator_t
> >
, remove_const<Value> , std::remove_const<Value>
, add_const<Value> , std::add_const<Value>
>::type >::type
, typename access::reference , typename access::reference
>::type iterator_category; >::type iterator_category;

View File

@ -6,20 +6,12 @@
#ifndef BOOST_ITERATOR_CATEGORIES_HPP #ifndef BOOST_ITERATOR_CATEGORIES_HPP
# define BOOST_ITERATOR_CATEGORIES_HPP # define BOOST_ITERATOR_CATEGORIES_HPP
# include <boost/config.hpp>
# include <boost/iterator/detail/config_def.hpp>
# include <boost/detail/workaround.hpp>
# include <boost/mpl/eval_if.hpp> # include <boost/mpl/eval_if.hpp>
# include <boost/mpl/identity.hpp> # include <boost/mpl/identity.hpp>
# include <boost/mpl/placeholders.hpp> # include <boost/mpl/placeholders.hpp>
# include <boost/mpl/aux_/lambda_support.hpp> # include <boost/mpl/aux_/lambda_support.hpp>
# include <boost/type_traits/is_convertible.hpp> #include <type_traits>
# include <boost/static_assert.hpp>
#include <iterator> #include <iterator>
namespace boost { namespace boost {
@ -77,19 +69,19 @@ namespace detail
template <class Cat> template <class Cat>
struct old_category_to_traversal struct old_category_to_traversal
: mpl::eval_if< : mpl::eval_if<
is_convertible<Cat,std::random_access_iterator_tag> std::is_convertible<Cat,std::random_access_iterator_tag>
, mpl::identity<random_access_traversal_tag> , mpl::identity<random_access_traversal_tag>
, mpl::eval_if< , mpl::eval_if<
is_convertible<Cat,std::bidirectional_iterator_tag> std::is_convertible<Cat,std::bidirectional_iterator_tag>
, mpl::identity<bidirectional_traversal_tag> , mpl::identity<bidirectional_traversal_tag>
, mpl::eval_if< , mpl::eval_if<
is_convertible<Cat,std::forward_iterator_tag> std::is_convertible<Cat,std::forward_iterator_tag>
, mpl::identity<forward_traversal_tag> , mpl::identity<forward_traversal_tag>
, mpl::eval_if< , mpl::eval_if<
is_convertible<Cat,std::input_iterator_tag> std::is_convertible<Cat,std::input_iterator_tag>
, mpl::identity<single_pass_traversal_tag> , mpl::identity<single_pass_traversal_tag>
, mpl::eval_if< , mpl::eval_if<
is_convertible<Cat,std::output_iterator_tag> std::is_convertible<Cat,std::output_iterator_tag>
, mpl::identity<incrementable_traversal_tag> , mpl::identity<incrementable_traversal_tag>
, void , void
> >
@ -107,7 +99,7 @@ namespace detail
template <class Cat> template <class Cat>
struct iterator_category_to_traversal struct iterator_category_to_traversal
: mpl::eval_if< // if already convertible to a traversal tag, we're done. : mpl::eval_if< // if already convertible to a traversal tag, we're done.
is_convertible<Cat,incrementable_traversal_tag> std::is_convertible<Cat, incrementable_traversal_tag>
, mpl::identity<Cat> , mpl::identity<Cat>
, boost::iterators::detail::old_category_to_traversal<Cat> , boost::iterators::detail::old_category_to_traversal<Cat>
> >
@ -146,19 +138,19 @@ struct iterator_traversal<mpl::_>
template <class Traversal> template <class Traversal>
struct pure_traversal_tag struct pure_traversal_tag
: mpl::eval_if< : mpl::eval_if<
is_convertible<Traversal,random_access_traversal_tag> std::is_convertible<Traversal,random_access_traversal_tag>
, mpl::identity<random_access_traversal_tag> , mpl::identity<random_access_traversal_tag>
, mpl::eval_if< , mpl::eval_if<
is_convertible<Traversal,bidirectional_traversal_tag> std::is_convertible<Traversal,bidirectional_traversal_tag>
, mpl::identity<bidirectional_traversal_tag> , mpl::identity<bidirectional_traversal_tag>
, mpl::eval_if< , mpl::eval_if<
is_convertible<Traversal,forward_traversal_tag> std::is_convertible<Traversal,forward_traversal_tag>
, mpl::identity<forward_traversal_tag> , mpl::identity<forward_traversal_tag>
, mpl::eval_if< , mpl::eval_if<
is_convertible<Traversal,single_pass_traversal_tag> std::is_convertible<Traversal,single_pass_traversal_tag>
, mpl::identity<single_pass_traversal_tag> , mpl::identity<single_pass_traversal_tag>
, mpl::eval_if< , mpl::eval_if<
is_convertible<Traversal,incrementable_traversal_tag> std::is_convertible<Traversal,incrementable_traversal_tag>
, mpl::identity<incrementable_traversal_tag> , mpl::identity<incrementable_traversal_tag>
, void , void
> >
@ -211,6 +203,4 @@ using iterators::pure_traversal_tag;
} // namespace boost } // namespace boost
#include <boost/iterator/detail/config_undef.hpp>
#endif // BOOST_ITERATOR_CATEGORIES_HPP #endif // BOOST_ITERATOR_CATEGORIES_HPP

View File

@ -9,15 +9,7 @@
#include <boost/concept_check.hpp> #include <boost/concept_check.hpp>
#include <boost/iterator/iterator_categories.hpp> #include <boost/iterator/iterator_categories.hpp>
#include <boost/type_traits/is_same.hpp> #include <type_traits>
#include <boost/type_traits/is_integral.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/or.hpp>
#include <boost/static_assert.hpp>
// Use boost/limits to work around missing limits headers on some compilers // Use boost/limits to work around missing limits headers on some compilers
#include <boost/limits.hpp> #include <boost/limits.hpp>
@ -144,8 +136,8 @@ namespace boost_concepts
{ {
typedef typename std::iterator_traits<Iterator>::difference_type difference_type; typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
BOOST_STATIC_ASSERT(boost::is_integral<difference_type>::value); static_assert(std::is_integral<difference_type>::value, "difference_type must be integral.");
BOOST_STATIC_ASSERT(std::numeric_limits<difference_type>::is_signed); static_assert(std::numeric_limits<difference_type>::is_signed, "difference_type must be signed.");
BOOST_CONCEPT_ASSERT(( BOOST_CONCEPT_ASSERT((
boost::Convertible< boost::Convertible<

View File

@ -8,37 +8,24 @@
#define BOOST_ITERATOR_FACADE_23022003THW_HPP #define BOOST_ITERATOR_FACADE_23022003THW_HPP
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/iterator/interoperable.hpp> #include <boost/iterator/interoperable.hpp>
#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/enable_if.hpp> #include <boost/iterator/detail/type_traits/conjunction.hpp>
#include <boost/iterator/detail/type_traits/negation.hpp>
#include <boost/static_assert.hpp>
#include <boost/core/addressof.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_pointer.hpp>
#include <boost/type_traits/add_lvalue_reference.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_pod.hpp>
#include <boost/mpl/eval_if.hpp> #include <boost/mpl/eval_if.hpp>
#include <boost/mpl/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>
#include <boost/mpl/if.hpp>
#include <cstddef> #include <cstddef>
#include <type_traits>
#include <boost/iterator/detail/config_def.hpp> // this goes last #include <memory>
namespace boost { namespace boost {
namespace iterators { namespace iterators {
@ -64,7 +51,7 @@ namespace iterators {
// The type trait checks if the category or traversal is at least as advanced as the specified required traversal // The type trait checks if the category or traversal is at least as advanced as the specified required traversal
template< typename CategoryOrTraversal, typename Required > template< typename CategoryOrTraversal, typename Required >
struct is_traversal_at_least : struct is_traversal_at_least :
public boost::is_convertible< typename iterator_category_to_traversal< CategoryOrTraversal >::type, Required > public std::is_convertible< typename iterator_category_to_traversal< CategoryOrTraversal >::type, Required >
{}; {};
// //
@ -76,8 +63,8 @@ namespace iterators {
, class Return , class Return
> >
struct enable_if_interoperable : struct enable_if_interoperable :
public boost::iterators::enable_if< public std::enable_if<
is_interoperable< Facade1, Facade2 > is_interoperable<Facade1, Facade2>::value
, Return , Return
> >
{}; {};
@ -91,12 +78,12 @@ namespace iterators {
, class Return , class Return
> >
struct enable_if_interoperable_and_random_access_traversal : struct enable_if_interoperable_and_random_access_traversal :
public boost::iterators::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 >
> >::value
, Return , Return
> >
{}; {};
@ -117,31 +104,14 @@ namespace iterators {
CategoryOrTraversal, ValueParam, Reference CategoryOrTraversal, ValueParam, Reference
>::type iterator_category; >::type iterator_category;
typedef typename remove_const<ValueParam>::type value_type; typedef typename std::remove_const<ValueParam>::type value_type;
// Not the real associated pointer type // Not the real associated pointer type
typedef typename mpl::eval_if< typedef typename mpl::eval_if<
boost::iterators::detail::iterator_writability_disabled<ValueParam,Reference> boost::iterators::detail::iterator_writability_disabled<ValueParam,Reference>
, add_pointer<const value_type> , std::add_pointer<const value_type>
, add_pointer<value_type> , std::add_pointer<value_type>
>::type pointer; >::type pointer;
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
&& (BOOST_WORKAROUND(_STLPORT_VERSION, BOOST_TESTED_AT(0x452)) \
|| BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, BOOST_TESTED_AT(310))) \
|| BOOST_WORKAROUND(BOOST_RWSTD_VER, BOOST_TESTED_AT(0x20101)) \
|| BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, <= 310)
// To interoperate with some broken library/compiler
// combinations, user-defined iterators must be derived from
// std::iterator. It is possible to implement a standard
// library for broken compilers without this limitation.
# define BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE 1
typedef
iterator<iterator_category, value_type, Difference, pointer, Reference>
base;
# endif
}; };
// iterators whose dereference operators reference the same value // iterators whose dereference operators reference the same value
@ -180,7 +150,7 @@ namespace iterators {
// Provides (r++)->foo() // Provides (r++)->foo()
value_type* operator->() const value_type* operator->() const
{ {
return boost::addressof(stored_value); return std::addressof(stored_value);
} }
private: private:
@ -240,38 +210,15 @@ namespace iterators {
} }
// Provides writability of *r++ // Provides writability of *r++
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template <class T> template <class T>
typename iterators::enable_if< typename std::enable_if<
is_not_writable_postfix_increment_dereference_proxy< T >, is_not_writable_postfix_increment_dereference_proxy<T>::value,
writable_postfix_increment_dereference_proxy const& writable_postfix_increment_dereference_proxy const&
>::type operator=(T&& x) const >::type operator=(T&& x) const
{ {
*this->stored_iterator = static_cast< T&& >(x); *this->stored_iterator = static_cast< T&& >(x);
return *this; return *this;
} }
#else
template <class T>
typename iterators::enable_if<
is_not_writable_postfix_increment_dereference_proxy< T >,
writable_postfix_increment_dereference_proxy const&
>::type operator=(T const& x) const
{
*this->stored_iterator = x;
return *this;
}
// This overload just in case only non-const objects are writable
template <class T>
typename iterators::enable_if<
is_not_writable_postfix_increment_dereference_proxy< T >,
writable_postfix_increment_dereference_proxy const&
>::type operator=(T& x) const
{
*this->stored_iterator = x;
return *this;
}
#endif
private: private:
Iterator stored_iterator; Iterator stored_iterator;
@ -303,49 +250,21 @@ namespace iterators {
// Provides (r++)->foo() // Provides (r++)->foo()
value_type* operator->() const value_type* operator->() const
{ {
return boost::addressof(dereference_proxy.stored_value); return std::addressof(dereference_proxy.stored_value);
} }
private: private:
writable_postfix_increment_dereference_proxy<Iterator> dereference_proxy; writable_postfix_increment_dereference_proxy<Iterator> dereference_proxy;
}; };
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class Reference, class Value>
struct is_non_proxy_reference_impl
{
static Reference r;
template <class R>
static typename mpl::if_<
is_convertible<
R const volatile*
, Value const volatile*
>
, char[1]
, char[2]
>::type& helper(R const&);
BOOST_STATIC_CONSTANT(bool, value = sizeof(helper(r)) == 1);
};
template <class Reference, class Value> template <class Reference, class Value>
struct is_non_proxy_reference struct is_non_proxy_reference
: mpl::bool_< : std::is_convertible<
is_non_proxy_reference_impl<Reference, Value>::value typename std::remove_reference<Reference>::type
>
{};
# else
template <class Reference, class Value>
struct is_non_proxy_reference
: is_convertible<
typename remove_reference<Reference>::type
const volatile* const volatile*
, Value const volatile* , Value const volatile*
> >
{}; {};
# endif
// A metafunction to choose the result type of postfix ++ // A metafunction to choose the result type of postfix ++
// //
@ -365,22 +284,22 @@ 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
is_convertible< std::is_convertible<
Reference Reference
// Use add_lvalue_reference to form `reference to Value` due to // Use add_lvalue_reference to form `reference to Value` due to
// some (strict) C++03 compilers (e.g. `gcc -std=c++03`) reject // some (strict) C++03 compilers (e.g. `gcc -std=c++03`) reject
// 'reference-to-reference' in the template which described in CWG // 'reference-to-reference' in the template which described in CWG
// DR106. // DR106.
// http://www.open-std.org/Jtc1/sc22/wg21/docs/cwg_defects.html#106 // http://www.open-std.org/Jtc1/sc22/wg21/docs/cwg_defects.html#106
, typename add_lvalue_reference<Value const>::type , typename std::add_lvalue_reference<Value const>::type
> >
// 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<
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
> >
@ -404,15 +323,15 @@ namespace iterators {
{ {
struct proxy struct proxy
{ {
explicit proxy(Reference const & x) : m_ref(x) {} explicit proxy(Reference const& x) : m_ref(x) {}
Reference* operator->() { return boost::addressof(m_ref); } Reference* operator->() { return std::addressof(m_ref); }
// This function is needed for MWCW and BCC, which won't call // This function is needed for MWCW and BCC, which won't call
// operator-> again automatically per 13.3.1.2 para 8 // operator-> again automatically per 13.3.1.2 para 8
operator Reference*() { return boost::addressof(m_ref); } operator Reference*() { return std::addressof(m_ref); }
Reference m_ref; Reference m_ref;
}; };
typedef proxy result_type; typedef proxy result_type;
static result_type apply(Reference const & x) static result_type apply(Reference const& x)
{ {
return result_type(x); return result_type(x);
} }
@ -424,7 +343,7 @@ namespace iterators {
typedef Pointer result_type; typedef Pointer result_type;
static result_type apply(T& x) static result_type apply(T& x)
{ {
return boost::addressof(x); return std::addressof(x);
} }
}; };
@ -463,11 +382,10 @@ 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, std::is_copy_constructible<ValueType>
// but is_POD will have to suffice in the meantime. , std::is_trivial<ValueType>
boost::is_POD<ValueType>
, iterator_writability_disabled<ValueType,Reference> , iterator_writability_disabled<ValueType,Reference>
> >
> >
@ -476,21 +394,21 @@ namespace iterators {
template <class Iterator, class Value, class Reference> template <class Iterator, class Value, class Reference>
struct operator_brackets_result struct operator_brackets_result
{ {
typedef typename mpl::if_< typedef typename std::conditional<
use_operator_brackets_proxy<Value,Reference> use_operator_brackets_proxy<Value,Reference>::value
, operator_brackets_proxy<Iterator> , operator_brackets_proxy<Iterator>
, Value , Value
>::type type; >::type type;
}; };
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;
} }
@ -498,19 +416,12 @@ namespace iterators {
struct choose_difference_type struct choose_difference_type
{ {
template <class I1, class I2> template <class I1, class I2>
struct apply struct apply : mpl::eval_if<
: std::is_convertible<I2,I1>
# ifdef BOOST_NO_ONE_WAY_ITERATOR_INTEROP
iterator_difference<I1>
# else
mpl::eval_if<
is_convertible<I2,I1>
, iterator_difference<I1> , iterator_difference<I1>
, iterator_difference<I2> , iterator_difference<I2>
> >
# endif
{}; {};
}; };
template < template <
@ -528,17 +439,6 @@ namespace iterators {
// Macros which describe the declarations of binary operators // Macros which describe the declarations of binary operators
# ifdef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
# define BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, enabler) \
template < \
class Derived1, class V1, class TC1, class Reference1, class Difference1 \
, class Derived2, class V2, class TC2, class Reference2, class Difference2 \
> \
prefix typename mpl::apply2<result_type,Derived1,Derived2>::type \
operator op( \
iterator_facade<Derived1, V1, TC1, Reference1, Difference1> const& lhs \
, iterator_facade<Derived2, V2, TC2, Reference2, Difference2> const& rhs)
# else
# define BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, enabler) \ # define BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, enabler) \
template < \ template < \
class Derived1, class V1, class TC1, class Reference1, class Difference1 \ class Derived1, class V1, class TC1, class Reference1, class Difference1 \
@ -551,7 +451,6 @@ namespace iterators {
operator op( \ operator op( \
iterator_facade<Derived1, V1, TC1, Reference1, Difference1> const& lhs \ iterator_facade<Derived1, V1, TC1, Reference1, Difference1> const& lhs \
, iterator_facade<Derived2, V2, TC2, Reference2, Difference2> const& rhs) , iterator_facade<Derived2, V2, TC2, Reference2, Difference2> const& rhs)
# endif
# define BOOST_ITERATOR_FACADE_INTEROP_HEAD(prefix, op, result_type) \ # define BOOST_ITERATOR_FACADE_INTEROP_HEAD(prefix, op, result_type) \
BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, boost::iterators::detail::enable_if_interoperable) BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, boost::iterators::detail::enable_if_interoperable)
@ -561,9 +460,12 @@ namespace iterators {
# define BOOST_ITERATOR_FACADE_PLUS_HEAD(prefix,args) \ # define BOOST_ITERATOR_FACADE_PLUS_HEAD(prefix,args) \
template <class Derived, class V, class TC, class R, class D> \ template <class Derived, class V, class TC, class R, class D> \
prefix typename boost::iterators::enable_if< \ prefix typename std::enable_if< \
boost::iterators::detail::is_traversal_at_least< TC, boost::iterators::random_access_traversal_tag >, \ boost::iterators::detail::is_traversal_at_least< \
Derived \ TC \
, boost::iterators::random_access_traversal_tag \
>::value \
, Derived \
>::type operator+ args >::type operator+ args
// //
@ -577,12 +479,6 @@ namespace iterators {
// //
class iterator_core_access class iterator_core_access
{ {
# if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
// Tasteless as this may seem, making all members public allows member templates
// to work in the absence of member template friends.
public:
# else
template <class I, class V, class TC, class R, class D> friend class iterator_facade; template <class I, class V, class TC, class R, class D> friend class iterator_facade;
template <class I, class V, class TC, class R, class D, bool IsBidirectionalTraversal, bool IsRandomAccessTraversal> template <class I, class V, class TC, class R, class D, bool IsBidirectionalTraversal, bool IsRandomAccessTraversal>
friend class detail::iterator_facade_base; friend class detail::iterator_facade_base;
@ -623,8 +519,6 @@ namespace iterators {
) )
; ;
# endif
template <class Facade> template <class Facade>
static typename Facade::reference dereference(Facade const& f) static typename Facade::reference dereference(Facade const& f)
{ {
@ -644,13 +538,13 @@ namespace iterators {
} }
template <class Facade1, class Facade2> template <class Facade1, class Facade2>
static bool equal(Facade1 const& f1, Facade2 const& f2, mpl::true_) static bool equal(Facade1 const& f1, Facade2 const& f2, std::true_type)
{ {
return f1.equal(f2); return f1.equal(f2);
} }
template <class Facade1, class Facade2> template <class Facade1, class Facade2>
static bool equal(Facade1 const& f1, Facade2 const& f2, mpl::false_) static bool equal(Facade1 const& f1, Facade2 const& f2, std::false_type)
{ {
return f2.equal(f1); return f2.equal(f1);
} }
@ -663,14 +557,14 @@ namespace iterators {
template <class Facade1, class Facade2> template <class Facade1, class Facade2>
static typename Facade1::difference_type distance_from( static typename Facade1::difference_type distance_from(
Facade1 const& f1, Facade2 const& f2, mpl::true_) Facade1 const& f1, Facade2 const& f2, std::true_type)
{ {
return -f1.distance_to(f2); return -f1.distance_to(f2);
} }
template <class Facade1, class Facade2> template <class Facade1, class Facade2>
static typename Facade2::difference_type distance_from( static typename Facade2::difference_type distance_from(
Facade1 const& f1, Facade2 const& f2, mpl::false_) Facade1 const& f1, Facade2 const& f2, std::false_type)
{ {
return f2.distance_to(f1); return f2.distance_to(f1);
} }
@ -705,12 +599,6 @@ namespace iterators {
, class Difference , class Difference
> >
class iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, false, false > class iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, false, false >
# ifdef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE
: public boost::iterators::detail::iterator_facade_types<
Value, CategoryOrTraversal, Reference, Difference
>::base
# undef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE
# endif
{ {
private: private:
typedef boost::iterators::detail::iterator_facade_types< typedef boost::iterators::detail::iterator_facade_types<
@ -811,11 +699,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; using use_proxy = boost::iterators::detail::use_operator_brackets_proxy<Value, Reference>;
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::value>{}
); );
} }
@ -950,19 +838,11 @@ namespace iterators {
// ---------------- // ----------------
// //
# ifdef BOOST_NO_ONE_WAY_ITERATOR_INTEROP # define BOOST_ITERATOR_CONVERTIBLE(a,b) std::is_convertible<a,b>()
# define BOOST_ITERATOR_CONVERTIBLE(a,b) mpl::true_()
# else
# define BOOST_ITERATOR_CONVERTIBLE(a,b) is_convertible<a,b>()
# endif
# define BOOST_ITERATOR_FACADE_INTEROP(op, result_type, return_prefix, base_op) \ # define BOOST_ITERATOR_FACADE_INTEROP(op, result_type, return_prefix, base_op) \
BOOST_ITERATOR_FACADE_INTEROP_HEAD(inline, op, result_type) \ BOOST_ITERATOR_FACADE_INTEROP_HEAD(inline, op, result_type) \
{ \ { \
/* For those compilers that do not support enable_if */ \
BOOST_STATIC_ASSERT(( \
is_interoperable< Derived1, Derived2 >::value \
)); \
return_prefix iterator_core_access::base_op( \ return_prefix iterator_core_access::base_op( \
*static_cast<Derived1 const*>(&lhs) \ *static_cast<Derived1 const*>(&lhs) \
, *static_cast<Derived2 const*>(&rhs) \ , *static_cast<Derived2 const*>(&rhs) \
@ -987,12 +867,7 @@ namespace iterators {
# define BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS(op, result_type, return_prefix, base_op) \ # define BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS(op, result_type, return_prefix, base_op) \
BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(inline, op, result_type) \ BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(inline, op, result_type) \
{ \ { \
/* For those compilers that do not support enable_if */ \ using boost::iterators::detail::is_traversal_at_least; \
BOOST_STATIC_ASSERT(( \
is_interoperable< Derived1, Derived2 >::value && \
boost::iterators::detail::is_traversal_at_least< typename iterator_category< Derived1 >::type, random_access_traversal_tag >::value && \
boost::iterators::detail::is_traversal_at_least< typename iterator_category< Derived2 >::type, random_access_traversal_tag >::value \
)); \
return_prefix iterator_core_access::base_op( \ return_prefix iterator_core_access::base_op( \
*static_cast<Derived1 const*>(&lhs) \ *static_cast<Derived1 const*>(&lhs) \
, *static_cast<Derived2 const*>(&rhs) \ , *static_cast<Derived2 const*>(&rhs) \
@ -1057,6 +932,4 @@ using iterators::iterator_facade;
} // namespace boost } // namespace boost
#include <boost/iterator/detail/config_undef.hpp>
#endif // BOOST_ITERATOR_FACADE_23022003THW_HPP #endif // BOOST_ITERATOR_FACADE_23022003THW_HPP

View File

@ -4,9 +4,7 @@
#ifndef BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_ #ifndef BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_
# define BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_ # define BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_
# include <boost/static_assert.hpp> # include <type_traits>
# include <boost/type_traits/is_convertible.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/mpl/placeholders.hpp> # include <boost/mpl/placeholders.hpp>
# include <boost/mpl/aux_/lambda_support.hpp> # include <boost/mpl/aux_/lambda_support.hpp>
@ -44,7 +42,10 @@ struct minimum_category_impl<true,true>
{ {
template <class T1, class T2> struct apply template <class T1, class T2> struct apply
{ {
BOOST_STATIC_ASSERT((is_same<T1,T2>::value)); static_assert(
std::is_same<T1,T2>::value,
"Iterator category types must be the same when they are equivalent."
);
typedef T1 type; typedef T1 type;
}; };
}; };
@ -68,8 +69,8 @@ template <class T1 = mpl::_1, class T2 = mpl::_2>
struct minimum_category struct minimum_category
{ {
typedef boost::iterators::detail::minimum_category_impl< typedef boost::iterators::detail::minimum_category_impl<
::boost::is_convertible<T1,T2>::value std::is_convertible<T1,T2>::value
, ::boost::is_convertible<T2,T1>::value , std::is_convertible<T2,T1>::value
> outer; > outer;
typedef typename outer::template apply<T1,T2> inner; typedef typename outer::template apply<T1,T2> inner;

View File

@ -1,5 +1,5 @@
#ifndef BOOST_NEW_ITERATOR_TESTS_HPP #ifndef BOOST_NEW_ITERATOR_TESTS_HPP
# define BOOST_NEW_ITERATOR_TESTS_HPP #define BOOST_NEW_ITERATOR_TESTS_HPP
// //
// Copyright (c) David Abrahams 2001. // Copyright (c) David Abrahams 2001.
@ -28,38 +28,34 @@
// 04 Feb 2001 Added lvalue test, corrected preconditions // 04 Feb 2001 Added lvalue test, corrected preconditions
// (David Abrahams) // (David Abrahams)
# include <iterator> #include <boost/concept_archetype.hpp> // for detail::dummy_constructor
# include <boost/static_assert.hpp> #include <boost/iterator/is_lvalue_iterator.hpp>
# include <boost/concept_archetype.hpp> // for detail::dummy_constructor #include <boost/iterator/is_readable_iterator.hpp>
# include <boost/pending/iterator_tests.hpp> #include <boost/pending/iterator_tests.hpp>
# include <boost/iterator/is_readable_iterator.hpp> #include <boost/core/lightweight_test.hpp>
# include <boost/iterator/is_lvalue_iterator.hpp> #include <boost/detail/is_incrementable.hpp>
# include <boost/type_traits/is_same.hpp> #include <boost/iterator/detail/type_traits/conjunction.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/mpl/and.hpp>
# include <boost/iterator/detail/config_def.hpp> #include <iterator>
# include <boost/detail/is_incrementable.hpp> #include <type_traits>
# include <boost/core/lightweight_test.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;
@ -68,10 +64,9 @@ 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)
@ -85,28 +80,28 @@ void readable_iterator_test(const Iterator i1, T v)
BOOST_TEST(v1 == v); BOOST_TEST(v1 == v);
BOOST_TEST(v2 == v); BOOST_TEST(v2 == v);
# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) readable_iterator_traversal_test(
readable_iterator_traversal_test(i1, v, detail::is_postfix_incrementable<Iterator>()); 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.
BOOST_STATIC_ASSERT(is_readable_iterator<Iterator>::value); static_assert(is_readable_iterator<Iterator>::value,
# endif "Iterator must be readable.");
} }
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)
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
} }
template <class Iterator> template <class Iterator>
@ -120,40 +115,43 @@ 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;
BOOST_STATIC_ASSERT((is_same<const value_type&, reference>::value)); 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; const T& v2 = *i2;
BOOST_TEST(v1 == v2); BOOST_TEST(v1 == v2);
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION #ifndef BOOST_NO_LVALUE_RETURN_DETECTION
BOOST_STATIC_ASSERT(is_lvalue_iterator<Iterator>::value); static_assert(is_lvalue_iterator<Iterator>::value
BOOST_STATIC_ASSERT(!is_non_const_lvalue_iterator<Iterator>::value); && !is_non_const_lvalue_iterator<Iterator>::value,
# endif "Iterator must be a const lvalue iterator.");
#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;
BOOST_STATIC_ASSERT((is_same<value_type&, reference>::value)); 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; T& v3 = *i2;
BOOST_TEST(v1 == v3); BOOST_TEST(v1 == v3);
// A non-const lvalue iterator is not neccessarily writable, but we // A non-const lvalue iterator is not necessarily writable, but we
// are assuming the value_type is assignable here // are assuming the value_type is assignable here
*i = v2; *i = v2;
T& v4 = *i2; T& v4 = *i2;
BOOST_TEST(v2 == v4); BOOST_TEST(v2 == v4);
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION static_assert(is_lvalue_iterator<Iterator>::value,
BOOST_STATIC_ASSERT(is_lvalue_iterator<Iterator>::value); "Iterator must be an lvalue iterator.");
BOOST_STATIC_ASSERT(is_non_const_lvalue_iterator<Iterator>::value); static_assert(is_non_const_lvalue_iterator<Iterator>::value,
# endif "Iterator must be non-const.");
} }
template <class Iterator, class T> template <class Iterator, class T>
@ -226,7 +224,7 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals)
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]);
@ -242,7 +240,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]);
@ -260,6 +258,4 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals)
} // namespace boost } // namespace boost
# include <boost/iterator/detail/config_undef.hpp>
#endif // BOOST_NEW_ITERATOR_TESTS_HPP #endif // BOOST_NEW_ITERATOR_TESTS_HPP

View File

@ -9,30 +9,13 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/config/workaround.hpp> #include <boost/config/workaround.hpp>
#include <boost/iterator/detail/enable_if.hpp>
#include <boost/iterator/iterator_adaptor.hpp> #include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_categories.hpp> #include <boost/iterator/iterator_categories.hpp>
#include <boost/type_traits/function_traits.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_function.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
#include <type_traits>
#include <iterator> #include <iterator>
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
#include <boost/type_traits/is_base_and_derived.hpp>
#endif
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
#include <boost/static_assert.hpp>
#endif
#include <boost/iterator/detail/config_def.hpp>
namespace boost { namespace boost {
namespace iterators { namespace iterators {
@ -103,7 +86,7 @@ namespace iterators {
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) #if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
// don't provide this constructor if UnaryFunc is a // don't provide this constructor if UnaryFunc is a
// function pointer type, since it will be 0. Too dangerous. // function pointer type, since it will be 0. Too dangerous.
BOOST_STATIC_ASSERT(is_class<UnaryFunc>::value); static_assert(std::is_class<UnaryFunc>::value, "Transform function must not be a function pointer.");
#endif #endif
} }
@ -115,9 +98,7 @@ namespace iterators {
transform_iterator( transform_iterator(
transform_iterator<OtherUnaryFunction, OtherIterator, OtherReference, OtherValue> const& t transform_iterator<OtherUnaryFunction, OtherIterator, OtherReference, OtherValue> const& t
, typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1310)
, typename enable_if_convertible<OtherUnaryFunction, UnaryFunc>::type* = 0 , typename enable_if_convertible<OtherUnaryFunction, UnaryFunc>::type* = 0
#endif
) )
: super_t(t.base()), m_f(t.functor()) : super_t(t.base()), m_f(t.functor())
{} {}
@ -149,24 +130,14 @@ namespace iterators {
// function pointer in the iterator be 0, leading to a runtime // function pointer in the iterator be 0, leading to a runtime
// crash. // crash.
template <class UnaryFunc, class Iterator> template <class UnaryFunc, class Iterator>
inline typename iterators::enable_if< inline typename std::enable_if<
is_class<UnaryFunc> // We should probably find a cheaper test than is_class<> std::is_class<UnaryFunc>::value // We should probably find a cheaper test than is_class<>
, transform_iterator<UnaryFunc, Iterator> , transform_iterator<UnaryFunc, Iterator>
>::type >::type
make_transform_iterator(Iterator it) make_transform_iterator(Iterator it)
{ {
return transform_iterator<UnaryFunc, Iterator>(it, UnaryFunc()); return transform_iterator<UnaryFunc, Iterator>(it, UnaryFunc());
} }
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
template <class Return, class Argument, class Iterator>
inline transform_iterator< Return (*)(Argument), Iterator, Return>
make_transform_iterator(Iterator it, Return (*fun)(Argument))
{
return transform_iterator<Return (*)(Argument), Iterator, Return>(it, fun);
}
#endif
} // namespace iterators } // namespace iterators
using iterators::transform_iterator; using iterators::transform_iterator;
@ -174,6 +145,4 @@ using iterators::make_transform_iterator;
} // namespace boost } // namespace boost
#include <boost/iterator/detail/config_undef.hpp>
#endif // BOOST_TRANSFORM_ITERATOR_23022003THW_HPP #endif // BOOST_TRANSFORM_ITERATOR_23022003THW_HPP

View File

@ -8,25 +8,20 @@
#ifndef BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_ #ifndef BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_
# define BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_ # define BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_
#include <stddef.h>
#include <boost/iterator/iterator_traits.hpp> #include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/iterator_facade.hpp> #include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/iterator_adaptor.hpp> // for enable_if_convertible #include <boost/iterator/iterator_adaptor.hpp> // for enable_if_convertible
#include <boost/iterator/iterator_categories.hpp> #include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/minimum_category.hpp> #include <boost/iterator/minimum_category.hpp>
#include <utility> // for std::pair #include <utility> // for std::pair
#include <boost/fusion/adapted/boost_tuple.hpp> // for backward compatibility
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/mpl/at.hpp> #include <boost/mpl/at.hpp>
#include <boost/mpl/fold.hpp> #include <boost/mpl/fold.hpp>
#include <boost/mpl/transform.hpp> #include <boost/mpl/transform.hpp>
#include <boost/mpl/placeholders.hpp> #include <boost/mpl/placeholders.hpp>
#include <boost/fusion/adapted/boost_tuple.hpp> // for backward compatibility
#include <boost/fusion/algorithm/iteration/for_each.hpp> #include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/fusion/algorithm/transformation/transform.hpp> #include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/fusion/sequence/convert.hpp> #include <boost/fusion/sequence/convert.hpp>
@ -83,7 +78,7 @@ namespace iterators {
struct result<This(Iterator)> struct result<This(Iterator)>
{ {
typedef typename typedef typename
remove_cv<typename remove_reference<Iterator>::type>::type std::remove_cv<typename std::remove_reference<Iterator>::type>::type
iterator; iterator;
typedef typename iterator_reference<iterator>::type type; typedef typename iterator_reference<iterator>::type type;

View File

@ -20,13 +20,10 @@
// (David Abrahams) // (David Abrahams)
# include <iterator> # include <iterator>
# include <boost/static_assert.hpp> # include <type_traits>
# include <boost/concept_archetype.hpp> // for detail::dummy_constructor # include <boost/concept_archetype.hpp> // for detail::dummy_constructor
# include <boost/core/ignore_unused.hpp> # include <boost/core/ignore_unused.hpp>
# include <boost/core/lightweight_test.hpp> # include <boost/core/lightweight_test.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/type_traits/is_pointer.hpp>
# include <boost/type_traits/is_reference.hpp>
namespace boost { namespace boost {
@ -143,10 +140,11 @@ template <bool is_pointer> struct lvalue_test
typedef typename Iterator::reference reference; typedef typename Iterator::reference reference;
typedef typename Iterator::value_type value_type; typedef typename Iterator::value_type value_type;
# endif # endif
BOOST_STATIC_ASSERT(boost::is_reference<reference>::value); static_assert(std::is_reference<reference>::value, "reference must be a reference type.");
BOOST_STATIC_ASSERT((boost::is_same<reference,value_type&>::value static_assert(
|| boost::is_same<reference,const value_type&>::value 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."
);
} }
}; };
@ -180,7 +178,7 @@ void forward_iterator_test(Iterator i, T v1, T v2)
// borland doesn't allow non-type template parameters // borland doesn't allow non-type template parameters
# if !defined(BOOST_BORLANDC) || (BOOST_BORLANDC > 0x551) # if !defined(BOOST_BORLANDC) || (BOOST_BORLANDC > 0x551)
lvalue_test<(boost::is_pointer<Iterator>::value)>::check(i); lvalue_test<std::is_pointer<Iterator>::value>::check(i);
#endif #endif
} }

View File

@ -15,12 +15,10 @@
# include <boost/detail/is_incrementable.hpp> # include <boost/detail/is_incrementable.hpp>
# include <boost/iterator/iterator_traits.hpp> # include <boost/iterator/iterator_traits.hpp>
# include <boost/type_traits/add_const.hpp>
# include <boost/type_traits/remove_cv.hpp>
# include <boost/mpl/if.hpp>
# include <boost/mpl/eval_if.hpp> # include <boost/mpl/eval_if.hpp>
#include <iterator> #include <iterator>
#include <type_traits>
namespace boost { namespace boost {
@ -37,25 +35,11 @@ namespace detail
{ {
typedef typename std::iterator_traits<Iterator>::value_type value_type; typedef typename std::iterator_traits<Iterator>::value_type value_type;
struct impl typedef typename std::conditional<
{ std::is_const<
template <class T> typename std::remove_reference<decltype(*std::declval<Iterator&>())>::type
static char test(T const&); >::value
, typename std::add_const<value_type>::type
static char (& test(value_type&) )[2];
static Iterator& x;
};
BOOST_STATIC_CONSTANT(bool, is_constant = sizeof(impl::test(*impl::x)) == 1);
typedef typename mpl::if_c<
# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
::boost::detail::iterator_pointee<Iterator>::is_constant
# else
is_constant
# endif
, typename add_const<value_type>::type
, value_type , value_type
>::type type; >::type type;
}; };

View File

@ -30,13 +30,12 @@
#include <boost/iterator/new_iterator_tests.hpp> #include <boost/iterator/new_iterator_tests.hpp>
#include <boost/next_prior.hpp> #include <boost/next_prior.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#include <boost/limits.hpp> #include <boost/limits.hpp>
#include <algorithm> #include <algorithm>
#include <climits>
#include <iterator> #include <iterator>
#include <type_traits>
#include <stdlib.h> #include <stdlib.h>
#ifndef BOOST_BORLANDC #ifndef BOOST_BORLANDC
# include <boost/tuple/tuple.hpp> # include <boost/tuple/tuple.hpp>
@ -68,7 +67,7 @@ struct unsigned_assert_nonnegative
template <class T> template <class T>
struct assert_nonnegative struct assert_nonnegative
: boost::conditional< : std::conditional<
std::numeric_limits<T>::is_signed std::numeric_limits<T>::is_signed
, signed_assert_nonnegative<T> , signed_assert_nonnegative<T>
, unsigned_assert_nonnegative<T> , unsigned_assert_nonnegative<T>

View File

@ -7,15 +7,14 @@
#include <boost/iterator/filter_iterator.hpp> #include <boost/iterator/filter_iterator.hpp>
#include <boost/iterator/reverse_iterator.hpp> #include <boost/iterator/reverse_iterator.hpp>
#include <boost/iterator/new_iterator_tests.hpp> #include <boost/iterator/new_iterator_tests.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/concept_check.hpp> #include <boost/concept_check.hpp>
#include <boost/concept_archetype.hpp> #include <boost/concept_archetype.hpp>
#include <boost/iterator/iterator_concepts.hpp> #include <boost/iterator/iterator_concepts.hpp>
#include <boost/iterator/iterator_archetypes.hpp> #include <boost/iterator/iterator_archetypes.hpp>
#include <boost/cstdlib.hpp> #include <boost/cstdlib.hpp>
#include <type_traits>
#include <deque> #include <deque>
#include <iostream>
using boost::dummyT; using boost::dummyT;
@ -229,12 +228,12 @@ int main()
filter_iter(one_or_four(), array, array+N) filter_iter(one_or_four(), array, array+N)
, dummyT(1), dummyT(4)); , dummyT(1), dummyT(4));
BOOST_STATIC_ASSERT( static_assert(
(!boost::is_convertible< !std::is_convertible<
boost::iterator_traversal<filter_iter>::type boost::iterator_traversal<filter_iter>::type
, boost::random_access_traversal_tag , boost::random_access_traversal_tag
>::value >::value,
)); "Filter interator must have a random_access_traversal_tag.");
//# endif //# endif

View File

@ -11,14 +11,12 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_DECLTYPE)
// Force boost::result_of use decltype, even on compilers that don't support N3276. // Force boost::result_of use decltype, even on compilers that don't support N3276.
// This enables this test to also verify if the iterator works with lambdas // This enables this test to also verify if the iterator works with lambdas
// on such compilers with this config macro. Note that without the macro result_of // on such compilers with this config macro. Note that without the macro result_of
// (and consequently the iterator) is guaranteed to _not_ work, so this case is not // (and consequently the iterator) is guaranteed to _not_ work, so this case is not
// worth testing anyway. // worth testing anyway.
#define BOOST_RESULT_OF_USE_DECLTYPE #define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#include <boost/core/lightweight_test.hpp> #include <boost/core/lightweight_test.hpp>
#include <boost/iterator/function_input_iterator.hpp> #include <boost/iterator/function_input_iterator.hpp>
@ -108,8 +106,6 @@ int main()
BOOST_TEST_EQ(*it3, 54); BOOST_TEST_EQ(*it3, 54);
} }
#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) \
&& defined(BOOST_RESULT_OF_USE_DECLTYPE)
// test the iterator with lambda expressions // test the iterator with lambda expressions
int num = 42; int num = 42;
auto lambda_generator = [&num] { return num++; }; auto lambda_generator = [&num] { return num++; };
@ -123,7 +119,6 @@ int main()
BOOST_TEST_EQ(generated.size(), 10u); BOOST_TEST_EQ(generated.size(), 10u);
for(std::size_t i = 0; i != 10; ++i) for(std::size_t i = 0; i != 10; ++i)
BOOST_TEST_EQ(generated[i], static_cast<int>(42 + i)); BOOST_TEST_EQ(generated[i], static_cast<int>(42 + i));
#endif // BOOST_NO_CXX11_LAMBDAS
return boost::report_errors(); return boost::report_errors();
} }

View File

@ -44,7 +44,6 @@ int main()
BOOST_TEST_EQ(n, 6); BOOST_TEST_EQ(n, 6);
} }
#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
{ {
int n = 0; int n = 0;
auto it = boost::iterators::make_function_output_iterator([&n](int x) { n -= x; }); auto it = boost::iterators::make_function_output_iterator([&n](int x) { n -= x; });
@ -57,7 +56,6 @@ int main()
BOOST_TEST_EQ(n, -6); BOOST_TEST_EQ(n, -6);
} }
#endif
#if defined(__cpp_lib_concepts) && ( __cpp_lib_concepts >= 202002L ) #if defined(__cpp_lib_concepts) && ( __cpp_lib_concepts >= 202002L )
{ {

View File

@ -9,12 +9,10 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#include <iostream>
#include <boost/iterator/indirect_iterator.hpp> #include <boost/iterator/indirect_iterator.hpp>
#include <boost/static_assert.hpp>
#include "static_assert_same.hpp" #include "static_assert_same.hpp"
#include <boost/type_traits/same_traits.hpp> #include <type_traits>
struct zow { }; struct zow { };
@ -40,10 +38,12 @@ int main()
STATIC_ASSERT_SAME(Iter::pointer, int*); STATIC_ASSERT_SAME(Iter::pointer, int*);
STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t); STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t);
BOOST_STATIC_ASSERT((boost::is_convertible<Iter::iterator_category, static_assert(std::is_convertible<Iter::iterator_category,
std::random_access_iterator_tag>::value)); std::random_access_iterator_tag>::value,
BOOST_STATIC_ASSERT((boost::is_convertible<boost::iterator_traversal<Iter>::type, "Iter must have a random access category.");
boost::random_access_traversal_tag>::value)); static_assert(std::is_convertible<boost::iterator_traversal<Iter>::type,
boost::random_access_traversal_tag>::value,
"Iter must have a random_access_traversal_tag.");
} }
{ {
typedef boost::indirect_iterator<int const**> Iter; typedef boost::indirect_iterator<int const**> Iter;
@ -71,10 +71,12 @@ int main()
STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t); STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t);
BOOST_STATIC_ASSERT((boost::is_convertible<Iter::iterator_category, static_assert(std::is_convertible<Iter::iterator_category,
std::random_access_iterator_tag>::value)); std::random_access_iterator_tag>::value,
BOOST_STATIC_ASSERT((boost::is_convertible<boost::iterator_traversal<Iter>::type, "Iter must have a random access category.");
boost::random_access_traversal_tag>::value)); static_assert(std::is_convertible<boost::iterator_traversal<Iter>::type,
boost::random_access_traversal_tag>::value,
"Iter must have a random_access_traversal_tag.");
} }
{ {
typedef boost::indirect_iterator<char**, int, std::random_access_iterator_tag, long&, short> Iter; typedef boost::indirect_iterator<char**, int, std::random_access_iterator_tag, long&, short> Iter;

View File

@ -37,8 +37,7 @@
#if !defined(__SGI_STL_PORT) \ #if !defined(__SGI_STL_PORT) \
&& (defined(BOOST_MSVC_STD_ITERATOR) \ && (defined(BOOST_MSVC_STD_ITERATOR) \
|| BOOST_WORKAROUND(_CPPLIB_VER, <= 310) \ || BOOST_WORKAROUND(_CPPLIB_VER, <= 310))
|| BOOST_WORKAROUND(__GNUC__, <= 2))
// std container random-access iterators don't support mutable/const // std container random-access iterators don't support mutable/const
// interoperability (but may support const/mutable interop). // interoperability (but may support const/mutable interop).

View File

@ -8,12 +8,13 @@
// //
#include <boost/iterator/reverse_iterator.hpp> #include <boost/iterator/reverse_iterator.hpp>
#include <boost/cstdlib.hpp> #include <boost/cstdlib.hpp>
#include <type_traits>
int main() int main()
{ {
typedef boost::reverse_iterator<int*> rev_iter1; typedef boost::reverse_iterator<int*> rev_iter1;
typedef boost::reverse_iterator<char*> rev_iter2; typedef boost::reverse_iterator<char*> rev_iter2;
return boost::is_convertible<rev_iter1, rev_iter2>::value return std::is_convertible<rev_iter1, rev_iter2>::value
? boost::exit_failure : boost::exit_success; ? boost::exit_failure : boost::exit_success;
} }

View File

@ -4,15 +4,10 @@
#include <deque> #include <deque>
#include <iterator> #include <iterator>
#include <iostream>
#include <cstddef> // std::ptrdiff_t #include <cstddef> // std::ptrdiff_t
#include <boost/static_assert.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/iterator/is_lvalue_iterator.hpp> #include <boost/iterator/is_lvalue_iterator.hpp>
// Last, for BOOST_NO_LVALUE_RETURN_DETECTION
#include <boost/iterator/detail/config_def.hpp>
struct v struct v
{ {
v(); v();
@ -88,61 +83,90 @@ struct constant_lvalue_iterator
constant_lvalue_iterator operator++(int); constant_lvalue_iterator operator++(int);
}; };
int main() int main()
{ {
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<v*>::value); static_assert(boost::is_lvalue_iterator<v*>::value,
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<v const*>::value); "boost::is_lvalue_iterator<v*>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<std::deque<v>::iterator>::value); static_assert(boost::is_lvalue_iterator<v const*>::value,
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<std::deque<v>::const_iterator>::value); "boost::is_lvalue_iterator<v const*>::value is expected to be true.");
BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator<std::back_insert_iterator<std::deque<v> > >::value); static_assert(boost::is_lvalue_iterator<std::deque<v>::iterator>::value,
BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator<std::ostream_iterator<v> >::value); "boost::is_lvalue_iterator<std::deque<v>::iterator>::value.");
BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator<proxy_iterator<v> >::value); static_assert(boost::is_lvalue_iterator<std::deque<v>::const_iterator>::value,
BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator<proxy_iterator<int> >::value); "boost::is_lvalue_iterator<std::deque<v>::const_iterator>::value is expected to be true.");
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION static_assert(!boost::is_lvalue_iterator<std::back_insert_iterator<std::deque<v>>>::value,
BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator<value_iterator>::value); "boost::is_lvalue_iterator<std::back_insert_iterator<std::deque<v>>>::value is expected to be false.");
#endif static_assert(!boost::is_lvalue_iterator<std::ostream_iterator<v>>::value,
"boost::is_lvalue_iterator<std::ostream_iterator<v>>::value is expected to be false.");
static_assert(!boost::is_lvalue_iterator<proxy_iterator<v>>::value,
"boost::is_lvalue_iterator<proxy_iterator<v>>::value is expected to be false.");
static_assert(!boost::is_lvalue_iterator<proxy_iterator<int>>::value,
"boost::is_lvalue_iterator<proxy_iterator<int>>::value is expected to be false.");
static_assert(!boost::is_lvalue_iterator<value_iterator>::value,
"boost::is_lvalue_iterator<value_iterator>::value is expected to be false.");
// Make sure inaccessible copy constructor doesn't prevent // Make sure inaccessible copy constructor doesn't prevent
// reference binding // reference binding
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<noncopyable_iterator>::value); static_assert(boost::is_lvalue_iterator<noncopyable_iterator>::value,
"boost::is_lvalue_iterator<noncopyable_iterator>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<lvalue_iterator<v> >::value); static_assert(boost::is_lvalue_iterator<lvalue_iterator<v>>::value,
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<lvalue_iterator<int> >::value); "boost::is_lvalue_iterator<lvalue_iterator<v>>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<lvalue_iterator<char*> >::value); static_assert(boost::is_lvalue_iterator<lvalue_iterator<int>>::value,
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<lvalue_iterator<float> >::value); "boost::is_lvalue_iterator<lvalue_iterator<int>>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<lvalue_iterator<char*>>::value,
"boost::is_lvalue_iterator<lvalue_iterator<char*>>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<lvalue_iterator<float>>::value,
"boost::is_lvalue_iterator<lvalue_iterator<float>>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<v> >::value); static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<v>>::value,
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<int> >::value); "boost::is_lvalue_iterator<constant_lvalue_iterator<v>>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<char*> >::value); static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<int>>::value,
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<float> >::value); "boost::is_lvalue_iterator<constant_lvalue_iterator<int>>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<char*>>::value,
"boost::is_lvalue_iterator<constant_lvalue_iterator<char*>>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<float>>::value,
"boost::is_lvalue_iterator<constant_lvalue_iterator<float>>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<v*>::value); static_assert(boost::is_non_const_lvalue_iterator<v*>::value,
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<v const*>::value); "boost::is_non_const_lvalue_iterator<v*>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<std::deque<v>::iterator>::value); static_assert(!boost::is_non_const_lvalue_iterator<v const*>::value,
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<std::deque<v>::const_iterator>::value); "boost::is_non_const_lvalue_iterator<v const*>::value is expected to be false.");
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<std::back_insert_iterator<std::deque<v> > >::value); static_assert(boost::is_non_const_lvalue_iterator<std::deque<v>::iterator>::value,
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<std::ostream_iterator<v> >::value); "boost::is_non_const_lvalue_iterator<std::deque<v>::iterator>::value is expected to be true.");
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<proxy_iterator<v> >::value); static_assert(!boost::is_non_const_lvalue_iterator<std::deque<v>::const_iterator>::value,
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<proxy_iterator<int> >::value); "boost::is_non_const_lvalue_iterator<std::deque<v>::const_iterator>::value is expected to be false.");
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION static_assert(!boost::is_non_const_lvalue_iterator<std::back_insert_iterator<std::deque<v>>>::value,
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<value_iterator>::value); "boost::is_non_const_lvalue_iterator<std::back_insert_iterator<std::deque<v>>>::value is expected to be false.");
#endif static_assert(!boost::is_non_const_lvalue_iterator<std::ostream_iterator<v>>::value,
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<noncopyable_iterator>::value); "boost::is_non_const_lvalue_iterator<std::ostream_iterator<v>>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<proxy_iterator<v>>::value,
"boost::is_non_const_lvalue_iterator<proxy_iterator<v>>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<proxy_iterator<int>>::value,
"boost::is_non_const_lvalue_iterator<proxy_iterator<int>>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<value_iterator>::value,
"boost::is_non_const_lvalue_iterator<value_iterator>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<noncopyable_iterator>::value,
"boost::is_non_const_lvalue_iterator<noncopyable_iterator>::value is expected to be false.");
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<v> >::value); static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<v>>::value,
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) "boost::is_non_const_lvalue_iterator<lvalue_iterator<v>>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<int> >::value); static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<int>>::value,
#endif "boost::is_non_const_lvalue_iterator<lvalue_iterator<int>>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<char*> >::value); static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<char*>>::value,
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<float> >::value); "boost::is_non_const_lvalue_iterator<lvalue_iterator<char*>>::value is expected to be true.");
static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<float>>::value,
"boost::is_non_const_lvalue_iterator<lvalue_iterator<float>>::value is expected to be true.");
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<v> >::value); static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<v>>::value,
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<int> >::value); "boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<v>>::value is expected to be false.");
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<char*> >::value); static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<int>>::value,
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<float> >::value); "boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<int>>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<char*>>::value,
"boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<char*>>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<float>>::value,
"boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<float>>::value is expected to be false.");
return 0; return 0;
} }

View File

@ -4,15 +4,10 @@
#include <deque> #include <deque>
#include <iterator> #include <iterator>
#include <iostream>
#include <cstddef> // std::ptrdiff_t #include <cstddef> // std::ptrdiff_t
#include <boost/static_assert.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/iterator/is_readable_iterator.hpp> #include <boost/iterator/is_readable_iterator.hpp>
// Last, for BOOST_NO_LVALUE_RETURN_DETECTION
#include <boost/iterator/detail/config_def.hpp>
struct v struct v
{ {
v(); v();
@ -78,19 +73,29 @@ struct proxy_iterator2
int main() int main()
{ {
BOOST_STATIC_ASSERT(boost::is_readable_iterator<v*>::value); static_assert(boost::is_readable_iterator<v*>::value,
BOOST_STATIC_ASSERT(boost::is_readable_iterator<v const*>::value); "boost::is_readable_iterator<v*>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_readable_iterator<std::deque<v>::iterator>::value); static_assert(boost::is_readable_iterator<v const*>::value,
BOOST_STATIC_ASSERT(boost::is_readable_iterator<std::deque<v>::const_iterator>::value); "boost::is_readable_iterator<v const*>::value is expected to be true.");
BOOST_STATIC_ASSERT(!boost::is_readable_iterator<std::back_insert_iterator<std::deque<v> > >::value); static_assert(boost::is_readable_iterator<std::deque<v>::iterator>::value,
BOOST_STATIC_ASSERT(!boost::is_readable_iterator<std::ostream_iterator<v> >::value); "boost::is_readable_iterator<std::deque<v>::iterator>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_readable_iterator<proxy_iterator>::value); static_assert(boost::is_readable_iterator<std::deque<v>::const_iterator>::value,
BOOST_STATIC_ASSERT(!boost::is_readable_iterator<proxy_iterator2>::value); "boost::is_readable_iterator<std::deque<v>::const_iterator>::value is expected to be true.");
BOOST_STATIC_ASSERT(boost::is_readable_iterator<value_iterator>::value); static_assert(!boost::is_readable_iterator<std::back_insert_iterator<std::deque<v>>>::value,
"boost::is_readable_iterator<std::back_insert_iterator<std::deque<v>>>::value is expected to be false.");
static_assert(!boost::is_readable_iterator<std::ostream_iterator<v>>::value,
"boost::is_readable_iterator<std::ostream_iterator<v>>::value is expected to be false.");
static_assert(boost::is_readable_iterator<proxy_iterator>::value,
"boost::is_readable_iterator<proxy_iterator>::value is expected to be true.");
static_assert(!boost::is_readable_iterator<proxy_iterator2>::value,
"boost::is_readable_iterator<proxy_iterator2>::value is expected to be false.");
static_assert(boost::is_readable_iterator<value_iterator>::value,
"boost::is_readable_iterator<value_iterator>::value is expected to be true.");
// Make sure inaccessible copy constructor doesn't prevent // Make sure inaccessible copy constructor doesn't prevent
// readability // readability
BOOST_STATIC_ASSERT(boost::is_readable_iterator<noncopyable_iterator>::value); static_assert(boost::is_readable_iterator<noncopyable_iterator>::value,
"boost::is_readable_iterator<noncopyable_iterator>::value is expected to be true.");
return 0; return 0;
} }

View File

@ -13,10 +13,8 @@
#include <numeric> #include <numeric>
#include <boost/iterator/iterator_adaptor.hpp> #include <boost/iterator/iterator_adaptor.hpp>
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) #include <boost/iterator/is_readable_iterator.hpp>
# include <boost/iterator/is_readable_iterator.hpp> #include <boost/iterator/is_lvalue_iterator.hpp>
# include <boost/iterator/is_lvalue_iterator.hpp>
#endif
#include <boost/pending/iterator_tests.hpp> #include <boost/pending/iterator_tests.hpp>
# include <boost/core/lightweight_test.hpp> # include <boost/core/lightweight_test.hpp>
@ -29,8 +27,6 @@
#include "static_assert_same.hpp" #include "static_assert_same.hpp"
#include <boost/iterator/detail/config_def.hpp>
using boost::dummyT; using boost::dummyT;
typedef std::deque<int> storage; typedef std::deque<int> storage;
@ -56,9 +52,6 @@ struct ptr_iterator
, V* , V*
, V , V
, boost::random_access_traversal_tag , boost::random_access_traversal_tag
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
, V&
#endif
> >
{ {
private: private:
@ -67,9 +60,6 @@ private:
, V* , V*
, V , V
, boost::random_access_traversal_tag , boost::random_access_traversal_tag
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
, V&
#endif
> super_t; > super_t;
public: public:
@ -208,9 +198,10 @@ main()
test = static_assert_same<Iter1::reference, int&>::value; test = static_assert_same<Iter1::reference, int&>::value;
test = static_assert_same<Iter1::pointer, int*>::value; test = static_assert_same<Iter1::pointer, int*>::value;
test = static_assert_same<Iter1::difference_type, std::ptrdiff_t>::value; test = static_assert_same<Iter1::difference_type, std::ptrdiff_t>::value;
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) static_assert(
BOOST_STATIC_ASSERT((boost::is_convertible<Iter1::iterator_category, std::random_access_iterator_tag>::value)); std::is_convertible<Iter1::iterator_category, std::random_access_iterator_tag>::value,
#endif "Iterator must have a random access category."
);
} }
{ {
@ -219,16 +210,10 @@ main()
test = static_assert_same<Iter1::value_type, int>::value; test = static_assert_same<Iter1::value_type, int>::value;
test = static_assert_same<Iter1::reference, const int&>::value; test = static_assert_same<Iter1::reference, const int&>::value;
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) static_assert(boost::is_readable_iterator<Iter1>::value, "Iter1 is expected to be readable.");
BOOST_STATIC_ASSERT(boost::is_readable_iterator<Iter1>::value); static_assert(boost::is_lvalue_iterator<Iter1>::value, "Iter1 is expected to be lvalue iterator.");
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<Iter1>::value);
# endif
#endif
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) // borland drops constness
test = static_assert_same<Iter1::pointer, int const*>::value; test = static_assert_same<Iter1::pointer, int const*>::value;
#endif
} }
{ {
@ -238,14 +223,16 @@ main()
test = static_assert_same<Iter::value_type, int>::value; test = static_assert_same<Iter::value_type, int>::value;
test = static_assert_same<Iter::reference, int const&>::value; test = static_assert_same<Iter::reference, int const&>::value;
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) // borland drops constness
test = static_assert_same<Iter::pointer, int const*>::value; test = static_assert_same<Iter::pointer, int const*>::value;
#endif
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION static_assert(
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<BaseIter>::value); boost::is_non_const_lvalue_iterator<BaseIter>::value,
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<Iter>::value); "boost::is_non_const_lvalue_iterator<BaseIter>::value is expected to be true."
#endif );
static_assert(
boost::is_lvalue_iterator<Iter>::value,
"boost::is_lvalue_iterator<Iter>::value is expected to be true."
);
typedef modify_traversal<BaseIter, boost::incrementable_traversal_tag> IncrementableIter; typedef modify_traversal<BaseIter, boost::incrementable_traversal_tag> IncrementableIter;

View File

@ -8,8 +8,9 @@
#include <boost/iterator/new_iterator_tests.hpp> #include <boost/iterator/new_iterator_tests.hpp>
#include <boost/call_traits.hpp> #include <boost/call_traits.hpp>
#include <boost/type_traits/is_convertible.hpp> #include <type_traits>
#include <boost/core/enable_if.hpp>
#include "static_assert_same.hpp"
// This is a really, really limited test so far. All we're doing // This is a really, really limited test so far. All we're doing
// right now is checking that the postfix++ proxy for single-pass // right now is checking that the postfix++ proxy for single-pass
@ -120,7 +121,7 @@ struct wrapper
{ } { }
template <class U> template <class U>
wrapper(const wrapper<U>& other, wrapper(const wrapper<U>& other,
typename boost::enable_if< boost::is_convertible<U,T> >::type* = 0) typename std::enable_if< std::is_convertible<U,T>::value >::type* = 0)
: m_x(other.m_x) : m_x(other.m_x)
{ } { }
}; };
@ -144,19 +145,15 @@ struct iterator_with_proxy_reference
{ return wrapper<int&>(m_x); } { return wrapper<int&>(m_x); }
}; };
template <class T, class U>
void same_type(U const&)
{ BOOST_STATIC_ASSERT((boost::is_same<T,U>::value)); }
template <class I, class A> template <class I, class A>
struct abstract_iterator struct abstract_iterator
: boost::iterator_facade< : boost::iterator_facade<
abstract_iterator<I, A> abstract_iterator<I, A>
, A & , A&
// In order to be value type as a reference, traversal category has // In order to be value type as a reference, traversal category has
// to satisfy least forward traversal. // to satisfy least forward traversal.
, boost::forward_traversal_tag , boost::forward_traversal_tag
, A & , A&
> >
{ {
abstract_iterator(I iter) : iter(iter) {} abstract_iterator(I iter) : iter(iter) {}
@ -164,7 +161,7 @@ struct abstract_iterator
void increment() void increment()
{ ++iter; } { ++iter; }
A & dereference() const A& dereference() const
{ return *iter; } { return *iter; }
bool equal(abstract_iterator const& y) const bool equal(abstract_iterator const& y) const
@ -175,30 +172,30 @@ struct abstract_iterator
struct base struct base
{ {
virtual void assign(const base &) = 0; virtual void assign(const base&) = 0;
virtual bool equal(const base &) const = 0; virtual bool equal(const base&) const = 0;
}; };
struct derived : base struct derived : base
{ {
derived(int state) : state(state) { } derived(int state) : state(state) { }
derived(const derived &d) : state(d.state) { } derived(const derived& d) : state(d.state) { }
derived(const base &b) { derived::assign(b); } derived(const base& b) { derived::assign(b); }
virtual void assign(const base &b) virtual void assign(const base& b)
{ {
state = dynamic_cast<const derived &>(b).state; state = dynamic_cast<const derived& >(b).state;
} }
virtual bool equal(const base &b) const virtual bool equal(const base& b) const
{ {
return state == dynamic_cast<const derived &>(b).state; return state == dynamic_cast<const derived&>(b).state;
} }
int state; int state;
}; };
inline bool operator==(const base &lhs, const base &rhs) inline bool operator==(const base& lhs, const base& rhs)
{ {
return lhs.equal(rhs); return lhs.equal(rhs);
} }
@ -226,7 +223,7 @@ int main()
BOOST_TEST_EQ(val.private_mutator_count, 0); // mutator() should be invoked on an object returned by value BOOST_TEST_EQ(val.private_mutator_count, 0); // mutator() should be invoked on an object returned by value
BOOST_TEST_EQ(shared_mutator_count, 2); BOOST_TEST_EQ(shared_mutator_count, 2);
same_type<input_iter::pointer>(p.operator->()); STATIC_ASSERT_SAME(input_iter::pointer, std::remove_cv<std::remove_reference<decltype(p.operator->())>::type>::type);
} }
{ {

View File

@ -20,15 +20,13 @@
// reference type from operator* (David Abrahams) // reference type from operator* (David Abrahams)
// 19 Jan 2001 Initial version with iterator operators (David Abrahams) // 19 Jan 2001 Initial version with iterator operators (David Abrahams)
#include <boost/type_traits/is_same.hpp>
#include <boost/operators.hpp> #include <boost/operators.hpp>
#include <boost/static_assert.hpp>
#include <boost/config.hpp> #include <boost/config.hpp>
#include <iterator> #include <iterator>
#include <vector> #include <vector>
#include <list> #include <list>
#include <boost/core/lightweight_test.hpp> #include <boost/core/lightweight_test.hpp>
#include <iostream> #include <type_traits>
// A UDT for which we can specialize std::iterator_traits<element*> on // A UDT for which we can specialize std::iterator_traits<element*> on
// compilers which don't support partial specialization. There's no // compilers which don't support partial specialization. There's no
@ -98,7 +96,7 @@ template <> struct assertion<true>
template <class T, class U> template <class T, class U>
struct assert_same struct assert_same
: assertion<(::boost::is_same<T,U>::value)> : assertion<(std::is_same<T,U>::value)>
{ {
}; };

View File

@ -6,10 +6,10 @@
#include <boost/iterator/minimum_category.hpp> #include <boost/iterator/minimum_category.hpp>
#include <boost/core/lightweight_test_trait.hpp> #include <boost/core/lightweight_test_trait.hpp>
#include <boost/type_traits/is_same.hpp>
#include <iterator> #include <iterator>
#include <type_traits>
using boost::is_same; using std::is_same;
using boost::iterators::minimum_category; using boost::iterators::minimum_category;
int main(int, char*[]) int main(int, char*[])

View File

@ -8,7 +8,6 @@
#include <boost/core/lightweight_test.hpp> #include <boost/core/lightweight_test.hpp>
#include <boost/iterator/permutation_iterator.hpp> #include <boost/iterator/permutation_iterator.hpp>
#include <boost/static_assert.hpp>
#include <boost/iterator/iterator_concepts.hpp> #include <boost/iterator/iterator_concepts.hpp>
#include <boost/concept/assert.hpp> #include <boost/concept/assert.hpp>
@ -44,7 +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;
BOOST_STATIC_ASSERT(index_size <= element_range_size); 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

@ -3,10 +3,10 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/pointee.hpp> #include <boost/pointee.hpp>
#include <boost/type_traits/add_const.hpp>
#include "static_assert_same.hpp" #include "static_assert_same.hpp"
#include <memory> #include <memory>
#include <list> #include <list>
#include <type_traits>
template <class T, class Ref> template <class T, class Ref>
struct proxy_ptr struct proxy_ptr
@ -27,7 +27,7 @@ struct proxy_ref_ptr : proxy_ptr<T,T&>
template <class T> template <class T>
struct proxy_value_ptr : proxy_ptr<T,T> struct proxy_value_ptr : proxy_ptr<T,T>
{ {
typedef typename boost::add_const<T>::type element_type; typedef typename std::add_const<T>::type element_type;
}; };
struct X { struct X {

View File

@ -5,10 +5,9 @@
#ifndef STATIC_ASSERT_SAME_DWA2003530_HPP #ifndef STATIC_ASSERT_SAME_DWA2003530_HPP
# define STATIC_ASSERT_SAME_DWA2003530_HPP # define STATIC_ASSERT_SAME_DWA2003530_HPP
#include <boost/static_assert.hpp> #include <type_traits>
#include <boost/type_traits/is_same.hpp>
#define STATIC_ASSERT_SAME( T1,T2 ) BOOST_STATIC_ASSERT((::boost::is_same< T1, T2 >::value)) #define STATIC_ASSERT_SAME( T1,T2 ) static_assert(std::is_same<T1, T2>::value, "T1 and T2 are expected to be the same types.")
template <class T1, class T2> template <class T1, class T2>
struct static_assert_same struct static_assert_same

View File

@ -21,15 +21,7 @@
#include <boost/pending/iterator_tests.hpp> #include <boost/pending/iterator_tests.hpp>
#include <boost/concept_check.hpp> #include <boost/concept_check.hpp>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #include "static_assert_same.hpp"
namespace boost { namespace detail
{
template<> struct function_object_result<int (*)(int)>
{
typedef int type;
};
}}
#endif
struct mult_functor { struct mult_functor {
// Functors used with transform_iterator must be // Functors used with transform_iterator must be
@ -172,20 +164,20 @@ main()
{ {
{ {
typedef boost::transform_iterator<adaptable_mult_functor, int*, float> iter_t; typedef boost::transform_iterator<adaptable_mult_functor, int*, float> iter_t;
BOOST_STATIC_ASSERT((boost::is_same<iter_t::reference, float>::value)); STATIC_ASSERT_SAME(iter_t::reference, float);
BOOST_STATIC_ASSERT((boost::is_same<iter_t::value_type, float>::value)); STATIC_ASSERT_SAME(iter_t::value_type, float);
} }
{ {
typedef boost::transform_iterator<adaptable_mult_functor, int*, boost::use_default, float> iter_t; typedef boost::transform_iterator<adaptable_mult_functor, int*, boost::use_default, float> iter_t;
BOOST_STATIC_ASSERT((boost::is_same<iter_t::reference, int>::value)); STATIC_ASSERT_SAME(iter_t::reference, int);
BOOST_STATIC_ASSERT((boost::is_same<iter_t::value_type, float>::value)); STATIC_ASSERT_SAME(iter_t::value_type, float);
} }
{ {
typedef boost::transform_iterator<adaptable_mult_functor, int*, float, double> iter_t; typedef boost::transform_iterator<adaptable_mult_functor, int*, float, double> iter_t;
BOOST_STATIC_ASSERT((boost::is_same<iter_t::reference, float>::value)); STATIC_ASSERT_SAME(iter_t::reference, float);
BOOST_STATIC_ASSERT((boost::is_same<iter_t::value_type, double>::value)); STATIC_ASSERT_SAME(iter_t::value_type, double);
} }
} }

View File

@ -3,10 +3,10 @@
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
#include <boost/iterator/iterator_adaptor.hpp> #include <boost/iterator/iterator_adaptor.hpp>
#include <boost/static_assert.hpp>
#include "static_assert_same.hpp" #include "static_assert_same.hpp"
#include <type_traits>
#include <boost/iterator/minimum_category.hpp> #include <boost/iterator/minimum_category.hpp>
struct X { int a; }; struct X { int a; };
@ -38,32 +38,30 @@ void category_test()
using namespace boost::iterators; using namespace boost::iterators;
using namespace boost::iterators::detail; using namespace boost::iterators::detail;
BOOST_STATIC_ASSERT(( static_assert(
!boost::is_convertible< !std::is_convertible<std::input_iterator_tag, input_output_iterator_tag>::value,
std::input_iterator_tag "std::input_iterator_tag is not expected to be convertible to input_output_iterator_tag.");
, input_output_iterator_tag>::value));
BOOST_STATIC_ASSERT(( static_assert(
!boost::is_convertible< !std::is_convertible<std::output_iterator_tag , input_output_iterator_tag>::value,
std::output_iterator_tag "std::output_iterator_tag is not expected to be convertible to input_output_iterator_tag.");
, input_output_iterator_tag>::value));
BOOST_STATIC_ASSERT(( static_assert(
boost::is_convertible< std::is_convertible<input_output_iterator_tag, std::input_iterator_tag>::value,
input_output_iterator_tag "input_output_iterator_tag is expected to be convertible to std::input_iterator_tag.");
, std::input_iterator_tag>::value));
BOOST_STATIC_ASSERT(( static_assert(
boost::is_convertible< std::is_convertible<input_output_iterator_tag, std::output_iterator_tag>::value,
input_output_iterator_tag "input_output_iterator_tag is expected to be convertible to std::output_iterator_tag.");
, std::output_iterator_tag>::value));
#if 0 // This seems wrong; we're not advertising #if 0 // This seems wrong; we're not advertising
// input_output_iterator_tag are we? // input_output_iterator_tag are we?
BOOST_STATIC_ASSERT(( static_assert(
boost::is_convertible< boost::is_convertible<
std::forward_iterator_tag std::forward_iterator_tag
, input_output_iterator_tag>::value)); , input_output_iterator_tag
>::value,
"");
#endif #endif
int test = static_assert_min_cat< int test = static_assert_min_cat<
@ -104,4 +102,3 @@ int main()
operator_arrow_test(); operator_arrow_test();
return 0; return 0;
} }