From 38818fbe3d850fdb02636a71a424dddcd44820d2 Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Tue, 20 Feb 2018 18:32:22 +0300 Subject: [PATCH 01/11] Add limits precheck --- .../fusion/container/deque/detail/cpp03/as_deque.hpp | 8 +++++++- .../boost/fusion/container/map/detail/cpp03/as_map.hpp | 8 +++++++- .../boost/fusion/container/set/detail/cpp03/as_set.hpp | 8 +++++++- .../fusion/container/vector/detail/cpp03/as_vector.hpp | 8 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/include/boost/fusion/container/deque/detail/cpp03/as_deque.hpp b/include/boost/fusion/container/deque/detail/cpp03/as_deque.hpp index e95daf3a..860a2a29 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/as_deque.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/as_deque.hpp @@ -26,7 +26,13 @@ namespace boost { namespace fusion { namespace detail BOOST_FUSION_BARRIER_BEGIN template - struct as_deque; + struct as_deque + { + BOOST_STATIC_ASSERT_MSG( + size <= FUSION_MAX_DEQUE_SIZE + , "FUSION_MAX_DEQUE_SIZE limit is too low" + ); + }; template <> struct as_deque<0> diff --git a/include/boost/fusion/container/map/detail/cpp03/as_map.hpp b/include/boost/fusion/container/map/detail/cpp03/as_map.hpp index efa836ba..442c350c 100644 --- a/include/boost/fusion/container/map/detail/cpp03/as_map.hpp +++ b/include/boost/fusion/container/map/detail/cpp03/as_map.hpp @@ -25,7 +25,13 @@ namespace boost { namespace fusion { namespace detail BOOST_FUSION_BARRIER_BEGIN template - struct as_map; + struct as_map + { + BOOST_STATIC_ASSERT_MSG( + size <= FUSION_MAX_MAP_SIZE + , "FUSION_MAX_MAP_SIZE limit is too low" + ); + }; template struct as_map<0, is_assoc> diff --git a/include/boost/fusion/container/set/detail/cpp03/as_set.hpp b/include/boost/fusion/container/set/detail/cpp03/as_set.hpp index c9159314..ec73a158 100644 --- a/include/boost/fusion/container/set/detail/cpp03/as_set.hpp +++ b/include/boost/fusion/container/set/detail/cpp03/as_set.hpp @@ -25,7 +25,13 @@ namespace boost { namespace fusion { namespace detail BOOST_FUSION_BARRIER_BEGIN template - struct as_set; + struct as_set + { + BOOST_STATIC_ASSERT_MSG( + size <= FUSION_MAX_SET_SIZE + , "FUSION_MAX_SET_SIZE limit is too low" + ); + }; template <> struct as_set<0> diff --git a/include/boost/fusion/container/vector/detail/cpp03/as_vector.hpp b/include/boost/fusion/container/vector/detail/cpp03/as_vector.hpp index bd7fa76b..471f7840 100644 --- a/include/boost/fusion/container/vector/detail/cpp03/as_vector.hpp +++ b/include/boost/fusion/container/vector/detail/cpp03/as_vector.hpp @@ -25,7 +25,13 @@ namespace boost { namespace fusion { namespace detail BOOST_FUSION_BARRIER_BEGIN template - struct as_vector; + struct as_vector + { + BOOST_STATIC_ASSERT_MSG( + size <= FUSION_MAX_VECTOR_SIZE + , "FUSION_MAX_VECTOR_SIZE limit is too low" + ); + }; template <> struct as_vector<0> From f61bffb21fba49caf66f65e6b8c848b04809d837 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 24 Feb 2018 16:00:57 +0900 Subject: [PATCH 02/11] Remove $$$ JDG temp $$$ --- test/sequence/deque_move.cpp | 2 +- test/sequence/map_move.cpp | 2 +- test/sequence/vector_move.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sequence/deque_move.cpp b/test/sequence/deque_move.cpp index b3675b24..b3bdf11b 100644 --- a/test/sequence/deque_move.cpp +++ b/test/sequence/deque_move.cpp @@ -5,7 +5,7 @@ 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) ==============================================================================*/ -#define BOOST_FUSION_DONT_USE_PREPROCESSED_FILES // $$$ JDG temp $$$ +#define BOOST_FUSION_DONT_USE_PREPROCESSED_FILES #include #define FUSION_SEQUENCE boost::fusion::deque> diff --git a/test/sequence/map_move.cpp b/test/sequence/map_move.cpp index fcac58aa..9f9dd004 100644 --- a/test/sequence/map_move.cpp +++ b/test/sequence/map_move.cpp @@ -5,7 +5,7 @@ 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) ==============================================================================*/ -#define BOOST_FUSION_DONT_USE_PREPROCESSED_FILES // $$$ JDG temp $$$ +#define BOOST_FUSION_DONT_USE_PREPROCESSED_FILES #include struct k1 {}; diff --git a/test/sequence/vector_move.cpp b/test/sequence/vector_move.cpp index 4e5ae7c8..3e9f0b6a 100644 --- a/test/sequence/vector_move.cpp +++ b/test/sequence/vector_move.cpp @@ -5,7 +5,7 @@ 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) ==============================================================================*/ -#define BOOST_FUSION_DONT_USE_PREPROCESSED_FILES // $$$ JDG temp $$$ +#define BOOST_FUSION_DONT_USE_PREPROCESSED_FILES #include #define FUSION_SEQUENCE boost::fusion::vector> From 82f677c169568df1ff767ce51dfded1df804bcc3 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 28 Feb 2018 20:03:07 -0800 Subject: [PATCH 03/11] Allow incomplete types in fusion::tag_of and fusion::is_native_fusion_sequence --- .../fusion/support/detail/is_mpl_sequence.hpp | 3 ++- include/boost/fusion/support/is_sequence.hpp | 9 +++++++-- test/Jamfile | 2 ++ test/support/is_sequence.cpp | 17 +++++++++++++++++ test/support/tag_of.cpp | 17 +++++++++++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 test/support/is_sequence.cpp create mode 100644 test/support/tag_of.cpp diff --git a/include/boost/fusion/support/detail/is_mpl_sequence.hpp b/include/boost/fusion/support/detail/is_mpl_sequence.hpp index 1c485f91..24b86624 100644 --- a/include/boost/fusion/support/detail/is_mpl_sequence.hpp +++ b/include/boost/fusion/support/detail/is_mpl_sequence.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include namespace boost { namespace fusion { namespace detail @@ -20,7 +21,7 @@ namespace boost { namespace fusion { namespace detail template struct is_mpl_sequence : mpl::and_< - mpl::not_ > + mpl::not_, is_convertible > > , mpl::is_sequence > {}; }}} diff --git a/include/boost/fusion/support/is_sequence.hpp b/include/boost/fusion/support/is_sequence.hpp index 6b9b2118..af7c84e1 100644 --- a/include/boost/fusion/support/is_sequence.hpp +++ b/include/boost/fusion/support/is_sequence.hpp @@ -10,9 +10,11 @@ #include #include #include +#include +#include #include #include -#include +#include #include #include @@ -69,7 +71,10 @@ namespace boost { namespace fusion template struct is_native_fusion_sequence - : is_convertible + : mpl::and_< + is_complete, + is_convertible + > {}; } }} diff --git a/test/Jamfile b/test/Jamfile index 82d715bb..a61239d0 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -254,6 +254,7 @@ project [ run functional/invoke_procedure.cpp ] [ run sequence/swap.cpp ] + [ compile support/is_sequence.cpp ] [ compile support/pair_deque.cpp ] [ compile support/pair_list.cpp ] [ compile support/pair_map.cpp ] @@ -264,6 +265,7 @@ project : [ requires cxx11_variadic_templates ] ] [ compile support/and.cpp : [ requires cxx11_variadic_templates ] ] + [ compile support/tag_of.cpp ] # [ compile-fail xxx.cpp ] diff --git a/test/support/is_sequence.cpp b/test/support/is_sequence.cpp new file mode 100644 index 00000000..428f6354 --- /dev/null +++ b/test/support/is_sequence.cpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2018 Louis Dionne + + 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) +==============================================================================*/ +#include +#include + + +// Make sure fusion::is_sequence and fusion::is_native_fusion_sequence can be +// used with an incomplete type. +struct incomplete; +BOOST_STATIC_ASSERT(!boost::fusion::traits::is_sequence::value); +BOOST_STATIC_ASSERT(!boost::fusion::traits::is_native_fusion_sequence::value); + +int main() { } diff --git a/test/support/tag_of.cpp b/test/support/tag_of.cpp new file mode 100644 index 00000000..ee2da10d --- /dev/null +++ b/test/support/tag_of.cpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2018 Louis Dionne + + 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) +==============================================================================*/ +#include +#include +#include + + +// Make sure tag_of can be used with an incomplete type. +struct incomplete; +typedef boost::fusion::traits::tag_of::type Tag; +BOOST_STATIC_ASSERT((boost::is_same::value)); + +int main() { } From c3dec40e72a5d5f5e741e21f02439d8dd990f3e2 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 13 Mar 2018 23:18:03 +0900 Subject: [PATCH 04/11] Fixed links to support list. Gmane had been closed and not back yet. --- doc/fusion.qbk | 6 ++---- doc/preface.qbk | 7 ++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/doc/fusion.qbk b/doc/fusion.qbk index 0a24cb32..76f64591 100644 --- a/doc/fusion.qbk +++ b/doc/fusion.qbk @@ -27,10 +27,8 @@ [def __tuple__ [@http://www.boost.org/libs/tuple/doc/tuple_users_guide.html Boost.Tuple]] [def __tr1__tuple__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1403.pdf TR1 Tuple]] [def __boost_tools__ [@http://www.boost.org/tools/index.html Boost Tools]] -[def __spirit_list__ [@https://lists.sourceforge.net/lists/listinfo/spirit-general Spirit Mailing List]] -[def __spirit_general__ [@news://news.gmane.org/gmane.comp.spirit.general Spirit General NNTP news portal]] -[def __gmane__ [@http://www.gmane.org Gmane]] -[def __mlist_archive__ [@http://news.gmane.org/gmane.comp.parsers.spirit.general]] +[def __spirit_list__ [@https://sourceforge.net/projects/spirit/lists/spirit-general Spirit Mailing List]] +[def __list_archive__ [@https://sourceforge.net/p/spirit/mailman/spirit-general/ archive]] [def __jaakko_jarvi__ [@http://www.boost.org/people/jaakko_jarvi.htm Jaakko Jarvi]] [def __david_abrahams__ [@http://www.boost.org/people/dave_abrahams.htm David Abrahams]] [def __the_forwarding_problem__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm The Forwarding Problem]] diff --git a/doc/preface.qbk b/doc/preface.qbk index 2fff963a..a6ab573f 100644 --- a/doc/preface.qbk +++ b/doc/preface.qbk @@ -61,11 +61,8 @@ tool. QuickBook can be found in the __boost_tools__. [heading Support] Please direct all questions to Spirit's mailing list. You can subscribe to the -__spirit_list__. The mailing list has a searchable archive. A search link to -this archive is provided in __spirit__'s home page. You may also read and post -messages to the mailing list through __spirit_general__ (thanks to __gmane__). -The news group mirrors the mailing list. Here is a link to the archives: -__mlist_archive__. +__spirit_list__. The mailing list has a searchable archive. Here is a link to +the archives: __list_archive__. [endsect] From d5bd71c8866a22c1c375e6acc9dc3dfd2e86c96b Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 14 Mar 2018 00:51:48 +0900 Subject: [PATCH 05/11] Update dead/moved links --- doc/fusion.qbk | 39 ++++++++++++++++++++------------------- doc/references.qbk | 17 +++++++++-------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/doc/fusion.qbk b/doc/fusion.qbk index 76f64591..6d6987d5 100644 --- a/doc/fusion.qbk +++ b/doc/fusion.qbk @@ -2,6 +2,7 @@ Copyright (C) 2001-2011 Joel de Guzman Copyright (C) 2006 Dan Marsden Copyright (C) 2010 Christopher Schmidt + Copyright (C) 2018 Kohei Takahashi Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -20,11 +21,11 @@ ] ] -[def __spirit__ [@http://spirit.sourceforge.net Spirit]] -[def __phoenix__ [@http://www.boost.org/libs/phoenix/index.html Phoenix]] -[def __mpl__ [@http://www.boost.org/libs/mpl/index.html MPL]] +[def __spirit__ [@http://boost-spirit.com/home/ Spirit]] +[def __phoenix__ [@http://www.boost.org/libs/phoenix Phoenix]] +[def __mpl__ [@http://www.boost.org/libs/mpl MPL]] [def __stl__ [@http://en.wikipedia.org/wiki/Standard_Template_Library STL]] -[def __tuple__ [@http://www.boost.org/libs/tuple/doc/tuple_users_guide.html Boost.Tuple]] +[def __tuple__ [@http://www.boost.org/libs/tuple Boost.Tuple]] [def __tr1__tuple__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1403.pdf TR1 Tuple]] [def __boost_tools__ [@http://www.boost.org/tools/index.html Boost Tools]] [def __spirit_list__ [@https://sourceforge.net/projects/spirit/lists/spirit-general Spirit Mailing List]] @@ -33,24 +34,24 @@ [def __david_abrahams__ [@http://www.boost.org/people/dave_abrahams.htm David Abrahams]] [def __the_forwarding_problem__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm The Forwarding Problem]] -[def __boost_any__ [@http://www.boost.org/doc/html/any.html Boost.Any]] +[def __boost_any__ [@http://www.boost.org/libs/any Boost.Any Library]] [def __new_iterator_concepts__ [@http://www.boost.org/libs/iterator/doc/new-iter-concepts.html New Iterator Concepts]] -[def __boost_array_library__ [@http://www.boost.org/doc/html/array.html Boost.Array Library]] -[def __boost_variant_library__ [@http://www.boost.org/doc/html/variant.html Boost.Variant Library]] -[def __boost_tuple_library__ [@http://www.boost.org/libs/tuple/doc/tuple_users_guide.html Boost.Tuple Library]] -[def __boost_ref__ [@http://www.boost.org/doc/html/ref.html Boost.Ref]] -[def __boost_ref_call__ [@http://www.boost.org/doc/html/ref.html `ref`]] -[def __boost_result_of__ [@http://www.boost.org/libs/utility/utility.htm#result_of Boost.ResultOf]] +[def __boost_array_library__ [@http://www.boost.org/libs/array Boost.Array Library]] +[def __boost_variant_library__ [@http://www.boost.org/libs/variant Boost.Variant Library]] +[def __boost_tuple_library__ [@http://www.boost.org/libs/tuple Boost.Tuple Library]] +[def __boost_ref__ [@http://www.boost.org/libs/core/ref.html Ref utility]] +[def __boost_ref_call__ [@http://www.boost.org/libs/core/ref.html `ref`]] +[def __boost_result_of__ [@http://www.boost.org/libs/utility/utility.htm#result_of ResultOf utility]] [def __boost_result_of_call__ [@http://www.boost.org/libs/utility/utility.htm#result_of `boost::result_of`]] -[def __boost_enable_if__ [@http://www.boost.org/libs/utility/enable_if.html Boost.EnableIf utility]] -[def __boost_shared_ptr_call__ [@http://www.boost.org/libs/smart_ptr/shared_ptr.htm `boost::shared_ptr`]] -[def __boost_func_forward__ [@http://www.boost.org/libs/functional/forward/doc/html/index.html Boost.Functional/Forward]] -[def __boost_func_factory__ [@http://www.boost.org/libs/functional/factory/doc/html/index.html Boost.Functional/Factory]] -[def __boost_func_hash__ [@http://www.boost.org/doc/html/hash.html Boost.Functional/Hash]] -[def __std_pair_doc__ [@http://www.sgi.com/tech/stl/pair.html `std::pair`]] +[def __boost_enable_if__ [@http://www.boost.org/libs/core/doc/html/core/enable_if.html EnableIf utility]] +[def __boost_shared_ptr_call__ [@http://www.boost.org/libs/smart_ptr#shared_ptr `boost::shared_ptr`]] +[def __boost_func_forward__ [@http://www.boost.org/libs/functional/forward Boost.Functional/Forward Library]] +[def __boost_func_factory__ [@http://www.boost.org/libs/functional/factory Boost.Functional/Factory Library]] +[def __boost_func_hash__ [@http://www.boost.org/doc/html/hash.html Boost.ContainerHash Library]] +[def __std_pair_doc__ [@http://en.cppreference.com/w/cpp/utility/pair `std::pair`]] [def __std_tuple_doc__ [@http://en.cppreference.com/w/cpp/utility/tuple `std::tuple`]] -[def __std_plus_doc__ [@http://www.sgi.com/tech/stl/plus.html `std::plus`]] -[def __std_minus_doc__ [@http://www.sgi.com/tech/stl/minus.html `std::minus`]] +[def __std_plus_doc__ [@http://en.cppreference.com/w/cpp/utility/functional/plus `std::plus`]] +[def __std_minus_doc__ [@http://en.cppreference.com/w/cpp/utility/functional/minus `std::minus`]] [def __mpl_integral_constant__ [@http://www.boost.org/libs/mpl/doc/refmanual/integral-constant.html MPL Integral Constant]] [def __mpl_boolean_constant__ [@http://www.boost.org/libs/mpl/doc/refmanual/integral-constant.html MPL Boolean Constant]] diff --git a/doc/references.qbk b/doc/references.qbk index d0d63019..a07815d4 100644 --- a/doc/references.qbk +++ b/doc/references.qbk @@ -1,6 +1,7 @@ [/============================================================================== Copyright (C) 2001-2011 Joel de Guzman Copyright (C) 2006 Dan Marsden + Copyright (C) 2018 Kohei Takahashi Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -8,20 +9,20 @@ ===============================================================================/] [section References] -# [@http://boost.org/libs/iterator/doc/new-iter-concepts.html New Iterator Concepts], +# [@http://www.boost.org/libs/iterator/doc/new-iter-concepts.html New Iterator Concepts], David Abrahams, Jeremy Siek, Thomas Witt, 2004-11-01. -# [@http://boost.org/libs/tuple/doc/tuple_users_guide.html The Boost Tuple Library], +# [@http://www.boost.org/libs/tuple The Boost Tuple Library], Jaakko Jarvi, 2001. -# [@http://www.boost.org/libs/spirit/ Spirit Parser Library], +# [@http://www.boost.org/libs/spirit Spirit Parser Library], Joel de Guzman, 2001-2006. -# [@http://www.boost.org/libs/mpl/ The Boost MPL Library], +# [@http://www.boost.org/libs/mpl The Boost MPL Library], Aleksey Gurtovoy and David Abrahams, 2002-2004. -# [@http://www.boost.org/doc/html/array.html Boost Array], +# [@http://www.boost.org/libs/array The Boost Array Library], Nicolai Josuttis, 2002-2004. -# [@http://www.sgi.com/tech/stl/ Standard Template Library Programmer's Guide], - Hewlett-Packard Company, 1994. -# [@http://www.boost.org/doc/html/ref.html Boost.Ref], +# [@http://www.boost.org/libs/core/ref.html Boost.Core / Ref utility], Jaakko Jarvi, Peter Dimov, Douglas Gregor, Dave Abrahams, 1999-2002. +# [@http://www.boost.org/libs/hana The Boost Hana Library], + Louis Dionne, 2017. [endsect] From 4734cf4a13c622ac92b777a33452558a4a06d26e Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 14 Mar 2018 14:41:43 +0900 Subject: [PATCH 06/11] Fixed detail::and test it should be used mpl/assert instead of runtime facility. --- test/support/and.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/test/support/and.cpp b/test/support/and.cpp index b657ead5..604a68d7 100644 --- a/test/support/and.cpp +++ b/test/support/and.cpp @@ -11,24 +11,18 @@ # error "does not meet requirements" #endif -#include #include #include -#include +#include -int main() { - using namespace boost; - using namespace boost::fusion::detail; - - BOOST_TEST((and_<>::value)); - BOOST_TEST(!(and_::value)); - BOOST_TEST((and_::value)); - BOOST_TEST(!(and_::value)); - BOOST_TEST((and_::value)); - BOOST_TEST(!(and_::value)); - BOOST_TEST((and_::value)); - BOOST_TEST((and_::value)); - - return boost::report_errors(); -} +using namespace boost; +using namespace boost::fusion::detail; +BOOST_MPL_ASSERT((and_<>)); +BOOST_MPL_ASSERT_NOT((and_)); +BOOST_MPL_ASSERT((and_)); +BOOST_MPL_ASSERT_NOT((and_)); +BOOST_MPL_ASSERT((and_)); +BOOST_MPL_ASSERT_NOT((and_)); +BOOST_MPL_ASSERT((and_)); +BOOST_MPL_ASSERT((and_)); From e962c1abb5312df23868a83ac66dd9da9773ca5f Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 18 Apr 2018 22:31:35 +0900 Subject: [PATCH 07/11] Fixed vector compile error with C-style array --- .../boost/fusion/container/vector/detail/value_at_impl.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/boost/fusion/container/vector/detail/value_at_impl.hpp b/include/boost/fusion/container/vector/detail/value_at_impl.hpp index a2b9b2f6..d7270aed 100644 --- a/include/boost/fusion/container/vector/detail/value_at_impl.hpp +++ b/include/boost/fusion/container/vector/detail/value_at_impl.hpp @@ -23,6 +23,7 @@ /////////////////////////////////////////////////////////////////////////////// #include #include +#include namespace boost { namespace fusion { @@ -35,7 +36,7 @@ namespace boost { namespace fusion template static inline BOOST_FUSION_GPU_ENABLED - U value_at_impl(store const volatile*); + mpl::identity value_at_impl(store const volatile*); } namespace extension @@ -49,8 +50,8 @@ namespace boost { namespace fusion template struct apply { - typedef - decltype(vector_detail::value_at_impl(boost::declval())) + typedef typename + decltype(vector_detail::value_at_impl(boost::declval()))::type type; }; }; From 96b2e51828e2df9bf6540a62687b9e62bf4039c8 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 18 Apr 2018 22:33:36 +0900 Subject: [PATCH 08/11] Added test for #176 --- test/Jamfile | 1 + test/sequence/github-176.cpp | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/sequence/github-176.cpp diff --git a/test/Jamfile b/test/Jamfile index a61239d0..9492e83f 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -237,6 +237,7 @@ project [ run sequence/ref_vector.cpp ] [ run sequence/flatten_view.cpp ] [ compile sequence/github-159.cpp ] + [ run sequence/github-176.cpp ] [ compile sequence/size.cpp ] diff --git a/test/sequence/github-176.cpp b/test/sequence/github-176.cpp new file mode 100644 index 00000000..553e83c2 --- /dev/null +++ b/test/sequence/github-176.cpp @@ -0,0 +1,50 @@ +/*============================================================================= + Copyright (c) 2018 Kohei Takahashi + + 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) +==============================================================================*/ + +#include +#include +#include +#include +#include +#include + +template +void test_at() +{ + Sequence seq; + + // zero initialized + BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 0); + BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 0); + BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 0); + + int (&arr)[3] = boost::fusion::deref(boost::fusion::begin(seq)); + + arr[0] = 2; + arr[1] = 4; + arr[2] = 6; + + BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 2); + BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 4); + BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 6); + + boost::fusion::at_c<0>(seq)[1] = 42; + + BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 2); + BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 42); + BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 6); +} + +int main() +{ + using namespace boost::fusion; + + test_at >(); + test_at >(); + test_at >(); + test_at >(); +} From dd695c1dbd07476d324fbd7973008fbafc129748 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 18 Apr 2018 22:38:09 +0900 Subject: [PATCH 09/11] Fixed a compile error bug similar to previous vector's one --- include/boost/fusion/container/map/detail/map_impl.hpp | 6 +----- .../fusion/container/map/detail/value_at_key_impl.hpp | 7 ++----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/include/boost/fusion/container/map/detail/map_impl.hpp b/include/boost/fusion/container/map/detail/map_impl.hpp index c62145ba..360c5d09 100644 --- a/include/boost/fusion/container/map/detail/map_impl.hpp +++ b/include/boost/fusion/container/map/detail/map_impl.hpp @@ -125,11 +125,7 @@ namespace boost { namespace fusion { namespace detail } BOOST_FUSION_GPU_ENABLED - value_type get_val(mpl::identity); - BOOST_FUSION_GPU_ENABLED - pair_type get_val(mpl::int_); - BOOST_FUSION_GPU_ENABLED - value_type get_val(mpl::identity) const; + mpl::identity get_val(mpl::identity) const; BOOST_FUSION_GPU_ENABLED pair_type get_val(mpl::int_) const; diff --git a/include/boost/fusion/container/map/detail/value_at_key_impl.hpp b/include/boost/fusion/container/map/detail/value_at_key_impl.hpp index 94d2da47..10873087 100644 --- a/include/boost/fusion/container/map/detail/value_at_key_impl.hpp +++ b/include/boost/fusion/container/map/detail/value_at_key_impl.hpp @@ -8,9 +8,6 @@ #define BOOST_FUSION_MAP_DETAIL_VALUE_AT_KEY_IMPL_02042013_0821 #include -#include -#include -#include #include #include @@ -29,8 +26,8 @@ namespace boost { namespace fusion template struct apply { - typedef - decltype(boost::declval().get_val(mpl::identity())) + typedef typename + decltype(boost::declval().get_val(mpl::identity()))::type type; }; }; From 757541f9d2f22faebf18665c3b6fe03203b428cf Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 18 Apr 2018 22:39:55 +0900 Subject: [PATCH 10/11] Updated c-style array test for associative container --- test/sequence/github-176.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/sequence/github-176.cpp b/test/sequence/github-176.cpp index 553e83c2..82960e9a 100644 --- a/test/sequence/github-176.cpp +++ b/test/sequence/github-176.cpp @@ -6,9 +6,12 @@ ==============================================================================*/ #include +#include #include #include #include +#include +#include #include #include @@ -39,6 +42,36 @@ void test_at() BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 6); } +template inline T& value(T& v) { return v; } +template inline T& value(boost::fusion::pair& v) { return v.second; } + +template +void test_at_key() +{ + Sequence seq; + + // zero initialized + BOOST_TEST(boost::fusion::at_key(seq)[0] == 0); + BOOST_TEST(boost::fusion::at_key(seq)[1] == 0); + BOOST_TEST(boost::fusion::at_key(seq)[2] == 0); + + int (&arr)[3] = value(boost::fusion::deref(boost::fusion::begin(seq))); + + arr[0] = 2; + arr[1] = 4; + arr[2] = 6; + + BOOST_TEST(boost::fusion::at_key(seq)[0] == 2); + BOOST_TEST(boost::fusion::at_key(seq)[1] == 4); + BOOST_TEST(boost::fusion::at_key(seq)[2] == 6); + + boost::fusion::at_key(seq)[1] = 42; + + BOOST_TEST(boost::fusion::at_key(seq)[0] == 2); + BOOST_TEST(boost::fusion::at_key(seq)[1] == 42); + BOOST_TEST(boost::fusion::at_key(seq)[2] == 6); +} + int main() { using namespace boost::fusion; @@ -47,4 +80,7 @@ int main() test_at >(); test_at >(); test_at >(); + + test_at_key >(); + test_at_key > >(); } From a273cd8131a5b5ebd25282e8c79f68e25a5f2610 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 19 Apr 2018 00:21:41 +0900 Subject: [PATCH 11/11] Added workaround for msvc-14.x --- .../container/map/detail/value_at_key_impl.hpp | 8 ++++---- .../container/vector/detail/value_at_impl.hpp | 9 ++++----- include/boost/fusion/support/config.hpp | 14 +++++++++++++- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/boost/fusion/container/map/detail/value_at_key_impl.hpp b/include/boost/fusion/container/map/detail/value_at_key_impl.hpp index 10873087..da6259e6 100644 --- a/include/boost/fusion/container/map/detail/value_at_key_impl.hpp +++ b/include/boost/fusion/container/map/detail/value_at_key_impl.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2013 Joel de Guzman + Copyright (c) 2018 Kohei Takahashi 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) @@ -8,7 +9,6 @@ #define BOOST_FUSION_MAP_DETAIL_VALUE_AT_KEY_IMPL_02042013_0821 #include -#include #include namespace boost { namespace fusion @@ -26,9 +26,9 @@ namespace boost { namespace fusion template struct apply { - typedef typename - decltype(boost::declval().get_val(mpl::identity()))::type - type; + typedef typename BOOST_FUSION_IDENTIFIED_TYPE(( + boost::declval().get_val(mpl::identity()) + )) type; }; }; } diff --git a/include/boost/fusion/container/vector/detail/value_at_impl.hpp b/include/boost/fusion/container/vector/detail/value_at_impl.hpp index d7270aed..a2dd5fcd 100644 --- a/include/boost/fusion/container/vector/detail/value_at_impl.hpp +++ b/include/boost/fusion/container/vector/detail/value_at_impl.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014,2018 Kohei Takahashi 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) @@ -7,7 +7,6 @@ #ifndef FUSION_VALUE_AT_IMPL_16122014_1641 #define FUSION_VALUE_AT_IMPL_16122014_1641 -#include #include #include @@ -50,9 +49,9 @@ namespace boost { namespace fusion template struct apply { - typedef typename - decltype(vector_detail::value_at_impl(boost::declval()))::type - type; + typedef typename BOOST_FUSION_IDENTIFIED_TYPE(( + vector_detail::value_at_impl(boost::declval()) + )) type; }; }; } diff --git a/include/boost/fusion/support/config.hpp b/include/boost/fusion/support/config.hpp index 23554531..65fe2f35 100644 --- a/include/boost/fusion/support/config.hpp +++ b/include/boost/fusion/support/config.hpp @@ -1,6 +1,6 @@ /*============================================================================= Copyright (c) 2014 Eric Niebler - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014,2018 Kohei Takahashi 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) @@ -96,4 +96,16 @@ namespace std #define BOOST_FUSION_CONSTEXPR_THIS BOOST_CONSTEXPR #endif + +// Workaround for compiler which doesn't compile decltype(expr)::type. +// It expects decltype(expr) deduced as mpl::identity. +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1913)) +# include +# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \ + boost::mpl::identity::type::type +#else +# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \ + decltype parenthesized_expr ::type +#endif + #endif