diff --git a/include/boost/fusion/view/reverse_view/detail/deref_data_impl.hpp b/include/boost/fusion/view/reverse_view/detail/deref_data_impl.hpp index e93b8fba..db64d32b 100644 --- a/include/boost/fusion/view/reverse_view/detail/deref_data_impl.hpp +++ b/include/boost/fusion/view/reverse_view/detail/deref_data_impl.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2009 Christopher Schmidt + Copyright (c) 2021-2022 Denis Mikhailov 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) @@ -10,6 +11,7 @@ #include #include +#include namespace boost { namespace fusion { namespace extension { @@ -23,14 +25,18 @@ namespace boost { namespace fusion { namespace extension struct apply { typedef typename - result_of::deref_data::type + result_of::deref_data< + typename result_of::prior< + typename It::first_type + >::type + >::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(It const& it) { - return fusion::deref_data(it.first); + return fusion::deref_data(fusion::prior(it.first)); } }; }; diff --git a/include/boost/fusion/view/reverse_view/detail/key_of_impl.hpp b/include/boost/fusion/view/reverse_view/detail/key_of_impl.hpp index 985e5fa9..0b8fc3bc 100644 --- a/include/boost/fusion/view/reverse_view/detail/key_of_impl.hpp +++ b/include/boost/fusion/view/reverse_view/detail/key_of_impl.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2009 Christopher Schmidt + Copyright (c) 2021-2022 Denis Mikhailov 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) @@ -10,6 +11,7 @@ #include #include +#include namespace boost { namespace fusion { namespace extension { @@ -21,8 +23,15 @@ namespace boost { namespace fusion { namespace extension { template struct apply - : result_of::key_of - {}; + { + typedef typename + result_of::key_of< + typename result_of::prior< + typename It::first_type + >::type + >::type + type; + }; }; }}} diff --git a/include/boost/fusion/view/reverse_view/detail/value_of_data_impl.hpp b/include/boost/fusion/view/reverse_view/detail/value_of_data_impl.hpp index a96d1ce3..03cb753f 100644 --- a/include/boost/fusion/view/reverse_view/detail/value_of_data_impl.hpp +++ b/include/boost/fusion/view/reverse_view/detail/value_of_data_impl.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2009 Christopher Schmidt + Copyright (c) 2021-2022 Denis Mikhailov 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) @@ -10,6 +11,7 @@ #include #include +#include namespace boost { namespace fusion { namespace extension { @@ -21,8 +23,15 @@ namespace boost { namespace fusion { namespace extension { template struct apply - : result_of::value_of_data - {}; + { + typedef typename + result_of::value_of_data< + typename result_of::prior< + typename It::first_type + >::type + >::type + type; + }; }; }}} diff --git a/test/sequence/reverse_view.cpp b/test/sequence/reverse_view.cpp index fb96275d..aded1522 100644 --- a/test/sequence/reverse_view.cpp +++ b/test/sequence/reverse_view.cpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2021-2022 Denis Mikhailov 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) @@ -15,6 +16,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -102,6 +106,21 @@ main() BOOST_TEST((at_c<2>(rev) == pair2("two"))); BOOST_TEST((at_c<3>(rev) == pair1("one"))); BOOST_TEST((at_c<4>(rev) == pair0("zero"))); + BOOST_TEST(( has_key< boost::mpl::int_<0> >(rev) + && has_key< boost::mpl::int_<4> >(rev) + && !has_key< boost::mpl::int_<-1> >(rev) + && !has_key< boost::mpl::int_<5> >(rev) )); + BOOST_TEST((at_key< boost::mpl::int_<0> >(rev) == "zero")); + BOOST_TEST((at_key< boost::mpl::int_<1> >(rev) == "one")); + BOOST_TEST((at_key< boost::mpl::int_<2> >(rev) == "two")); + BOOST_TEST((at_key< boost::mpl::int_<3> >(rev) == "three")); + BOOST_TEST((at_key< boost::mpl::int_<4> >(rev) == "four")); + BOOST_TEST(( (at_key< boost::mpl::int_<0> >(rev) = "new_zero") == "new_zero" + && at_key< boost::mpl::int_<0> >(rev) == "new_zero" )); + BOOST_MPL_ASSERT((boost::mpl::and_ > + , boost::mpl::not_ > > >)); + BOOST_MPL_ASSERT((boost::is_same>::type, std::string&>)); + BOOST_MPL_ASSERT((boost::is_same >::type, std::string>)); } return boost::report_errors();