mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-29 20:17:32 +02:00
Merge pull request #237 from denzor200/denzor200-patch-3
Fixed reverse_view
This commit is contained in:
@ -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 <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/iterator/deref_data.hpp>
|
||||
#include <boost/fusion/iterator/prior.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace extension
|
||||
{
|
||||
@ -23,14 +25,18 @@ namespace boost { namespace fusion { namespace extension
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
result_of::deref_data<typename It::first_type>::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));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -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 <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/iterator/key_of.hpp>
|
||||
#include <boost/fusion/iterator/prior.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace extension
|
||||
{
|
||||
@ -21,8 +23,15 @@ namespace boost { namespace fusion { namespace extension
|
||||
{
|
||||
template <typename It>
|
||||
struct apply
|
||||
: result_of::key_of<typename It::it_type>
|
||||
{};
|
||||
{
|
||||
typedef typename
|
||||
result_of::key_of<
|
||||
typename result_of::prior<
|
||||
typename It::first_type
|
||||
>::type
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
};
|
||||
}}}
|
||||
|
||||
|
@ -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 <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/iterator/value_of_data.hpp>
|
||||
#include <boost/fusion/iterator/prior.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace extension
|
||||
{
|
||||
@ -21,8 +23,15 @@ namespace boost { namespace fusion { namespace extension
|
||||
{
|
||||
template <typename It>
|
||||
struct apply
|
||||
: result_of::value_of_data<typename It::first_type>
|
||||
{};
|
||||
{
|
||||
typedef typename
|
||||
result_of::value_of_data<
|
||||
typename result_of::prior<
|
||||
typename It::first_type
|
||||
>::type
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
};
|
||||
}}}
|
||||
|
||||
|
@ -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 <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/iterator/prior.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
@ -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_<result_of::has_key<view_type, boost::mpl::int_<0> >
|
||||
, boost::mpl::not_<result_of::has_key<view_type, boost::mpl::int_<-1> > > >));
|
||||
BOOST_MPL_ASSERT((boost::is_same<result_of::at_key<view_type, boost::mpl::int_<0>>::type, std::string&>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_key<view_type, boost::mpl::int_<0> >::type, std::string>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
Reference in New Issue
Block a user