From 92de0326b55666614398e692127aff80105d66be Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Mon, 27 Feb 2023 14:29:50 -0800 Subject: [PATCH 1/3] Remove usage of boost/foreach_fwd.hpp in lieu of manual forward declaration + specialization --- .../boost/multi_index/detail/ord_index_impl.hpp | 16 ++++++++++------ include/boost/multi_index/hashed_index.hpp | 16 +++++++++------- .../boost/multi_index/random_access_index.hpp | 16 ++++++++++------ include/boost/multi_index/sequenced_index.hpp | 16 ++++++++++------ 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/include/boost/multi_index/detail/ord_index_impl.hpp b/include/boost/multi_index/detail/ord_index_impl.hpp index f7e6ced..c8568ae 100644 --- a/include/boost/multi_index/detail/ord_index_impl.hpp +++ b/include/boost/multi_index/detail/ord_index_impl.hpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -1725,16 +1724,21 @@ void swap( /* Boost.Foreach compatibility */ +namespace boost{ +namespace foreach{ + +template +struct is_noncopyable; + template< typename KeyFromValue,typename Compare, typename SuperMeta,typename TagList,typename Category,typename AugmentPolicy > -inline boost::mpl::true_* boost_foreach_is_noncopyable( +struct is_noncopyable< boost::multi_index::detail::ordered_index< - KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>*&, - boost_foreach_argument_dependent_lookup_hack) -{ - return 0; + KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy> +> : boost::mpl::true_ {}; +} } #undef BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT diff --git a/include/boost/multi_index/hashed_index.hpp b/include/boost/multi_index/hashed_index.hpp index d4ba37a..f1f0664 100644 --- a/include/boost/multi_index/hashed_index.hpp +++ b/include/boost/multi_index/hashed_index.hpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -1890,16 +1889,19 @@ struct hashed_non_unique /* Boost.Foreach compatibility */ +namespace boost{ +namespace foreach{ + +template +struct is_noncopyable; + template< typename KeyFromValue,typename Hash,typename Pred, typename SuperMeta,typename TagList,typename Category > -inline boost::mpl::true_* boost_foreach_is_noncopyable( - boost::multi_index::detail::hashed_index< - KeyFromValue,Hash,Pred,SuperMeta,TagList,Category>*&, - boost_foreach_argument_dependent_lookup_hack) -{ - return 0; +struct is_noncopyable > : boost::mpl::true_ {}; +} } #undef BOOST_MULTI_INDEX_HASHED_INDEX_CHECK_INVARIANT diff --git a/include/boost/multi_index/random_access_index.hpp b/include/boost/multi_index/random_access_index.hpp index c124746..8172784 100644 --- a/include/boost/multi_index/random_access_index.hpp +++ b/include/boost/multi_index/random_access_index.hpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -1343,12 +1342,17 @@ struct random_access /* Boost.Foreach compatibility */ +namespace boost{ +namespace foreach{ + +template +struct is_noncopyable; + template -inline boost::mpl::true_* boost_foreach_is_noncopyable( - boost::multi_index::detail::random_access_index*&, - boost_foreach_argument_dependent_lookup_hack) -{ - return 0; +struct is_noncopyable< + boost::multi_index::detail::random_access_index +> : boost::mpl::true_ {}; +} } #undef BOOST_MULTI_INDEX_RND_INDEX_CHECK_INVARIANT diff --git a/include/boost/multi_index/sequenced_index.hpp b/include/boost/multi_index/sequenced_index.hpp index f12213e..d09ad5d 100644 --- a/include/boost/multi_index/sequenced_index.hpp +++ b/include/boost/multi_index/sequenced_index.hpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -1238,12 +1237,17 @@ struct sequenced /* Boost.Foreach compatibility */ +namespace boost{ +namespace foreach{ + +template +struct is_noncopyable; + template -inline boost::mpl::true_* boost_foreach_is_noncopyable( - boost::multi_index::detail::sequenced_index*&, - boost_foreach_argument_dependent_lookup_hack) -{ - return 0; +struct is_noncopyable< + boost::multi_index::detail::sequenced_index +> : boost::mpl::true_ {}; +} } #undef BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT From 28e00a0ea6282fdb8ed49daa3f79a2c9583c60bb Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Mon, 27 Feb 2023 14:30:07 -0800 Subject: [PATCH 2/3] Add small test proving Boost.Foreach compatibility --- test/test_iterators.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test_iterators.cpp b/test/test_iterators.cpp index d9c7f7f..31e041d 100644 --- a/test/test_iterators.cpp +++ b/test/test_iterators.cpp @@ -15,6 +15,7 @@ #include "employee.hpp" #include #include +#include using namespace boost::multi_index; @@ -223,6 +224,24 @@ void test_const_rnd_iterators(const Index& i,int target) BOOST_TEST(n==target&&n==m&&n==p&&n==q); } +template +void test_boost_for_each(const Index& i,int) +{ + typedef typename Index::value_type value_type; + typedef typename Index::size_type size_type; + + size_type size=i.size(); + size_type count=0; + + BOOST_FOREACH(value_type const& x, i) + { + (void)x; + ++count; + } + + BOOST_TEST_EQ(count, size); +} + void test_iterators() { employee_set es; @@ -237,6 +256,7 @@ void test_iterators() test_non_const_iterators (es,target); test_const_iterators (es,target); + test_boost_for_each (es,target); test_non_const_hashed_iterators(get<1>(es),target); test_const_hashed_iterators (get<1>(es),target); test_non_const_iterators (get<2>(es),target); From 6163f597477f8b737a27cc1cb79a9c89e2eab889 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Wed, 1 Mar 2023 09:52:07 +0100 Subject: [PATCH 3/3] editorial, extended test_iterators --- include/boost/multi_index/detail/ord_index_impl.hpp | 5 +++-- include/boost/multi_index/hashed_index.hpp | 4 +++- include/boost/multi_index/random_access_index.hpp | 5 +++-- include/boost/multi_index/sequenced_index.hpp | 5 +++-- test/test_iterators.cpp | 7 ++++++- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/include/boost/multi_index/detail/ord_index_impl.hpp b/include/boost/multi_index/detail/ord_index_impl.hpp index c8568ae..0af68f9 100644 --- a/include/boost/multi_index/detail/ord_index_impl.hpp +++ b/include/boost/multi_index/detail/ord_index_impl.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2022 Joaquin M Lopez Munoz. +/* Copyright 2003-2023 Joaquin M Lopez Munoz. * 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) @@ -1737,7 +1737,8 @@ template< struct is_noncopyable< boost::multi_index::detail::ordered_index< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy> -> : boost::mpl::true_ {}; +>:boost::mpl::true_{}; + } } diff --git a/include/boost/multi_index/hashed_index.hpp b/include/boost/multi_index/hashed_index.hpp index f1f0664..5100d3c 100644 --- a/include/boost/multi_index/hashed_index.hpp +++ b/include/boost/multi_index/hashed_index.hpp @@ -1900,7 +1900,9 @@ template< typename SuperMeta,typename TagList,typename Category > struct is_noncopyable > : boost::mpl::true_ {}; + KeyFromValue,Hash,Pred,SuperMeta,TagList,Category> +>:boost::mpl::true_{}; + } } diff --git a/include/boost/multi_index/random_access_index.hpp b/include/boost/multi_index/random_access_index.hpp index 8172784..96b4565 100644 --- a/include/boost/multi_index/random_access_index.hpp +++ b/include/boost/multi_index/random_access_index.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2021 Joaquin M Lopez Munoz. +/* Copyright 2003-2023 Joaquin M Lopez Munoz. * 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) @@ -1351,7 +1351,8 @@ struct is_noncopyable; template struct is_noncopyable< boost::multi_index::detail::random_access_index -> : boost::mpl::true_ {}; +>:boost::mpl::true_{}; + } } diff --git a/include/boost/multi_index/sequenced_index.hpp b/include/boost/multi_index/sequenced_index.hpp index d09ad5d..770a6ce 100644 --- a/include/boost/multi_index/sequenced_index.hpp +++ b/include/boost/multi_index/sequenced_index.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2021 Joaquin M Lopez Munoz. +/* Copyright 2003-2023 Joaquin M Lopez Munoz. * 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) @@ -1246,7 +1246,8 @@ struct is_noncopyable; template struct is_noncopyable< boost::multi_index::detail::sequenced_index -> : boost::mpl::true_ {}; +>:boost::mpl::true_{}; + } } diff --git a/test/test_iterators.cpp b/test/test_iterators.cpp index 31e041d..a36b638 100644 --- a/test/test_iterators.cpp +++ b/test/test_iterators.cpp @@ -1,6 +1,6 @@ /* Boost.MultiIndex test for iterators. * - * Copyright 2003-2013 Joaquin M Lopez Munoz. + * Copyright 2003-2023 Joaquin M Lopez Munoz. * 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) @@ -259,12 +259,17 @@ void test_iterators() test_boost_for_each (es,target); test_non_const_hashed_iterators(get<1>(es),target); test_const_hashed_iterators (get<1>(es),target); + test_boost_for_each (get<1>(es),target); test_non_const_iterators (get<2>(es),target); test_const_iterators (get<2>(es),target); + test_boost_for_each (get<2>(es),target); test_non_const_iterators (get<3>(es),target); test_const_iterators (get<3>(es),target); + test_boost_for_each (get<3>(es),target); test_non_const_hashed_iterators(get<4>(es),target); test_const_hashed_iterators (get<4>(es),target); + test_boost_for_each (get<4>(es),target); test_non_const_rnd_iterators (get<5>(es),target); test_const_rnd_iterators (get<5>(es),target); + test_boost_for_each (get<5>(es),target); }