Merge pull request #90 from Flast/feature/variadic/nview

Variadic fusion::nview.
This commit is contained in:
Joel de Guzman
2015-07-16 14:07:41 +08:00
11 changed files with 60 additions and 32 deletions

View File

@ -1,7 +1,7 @@
/*============================================================================= /*=============================================================================
Copyright (c) 2009 Hartmut Kaiser Copyright (c) 2009 Hartmut Kaiser
Distributed under the Boost Software License, Version 1.0. (See accompanying 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) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/ ==============================================================================*/
@ -9,7 +9,6 @@
#define BOOST_FUSION_NVIEW_ADVANCE_IMPL_SEP_24_2009_0212PM #define BOOST_FUSION_NVIEW_ADVANCE_IMPL_SEP_24_2009_0212PM
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/mpl/advance.hpp>
#include <boost/fusion/iterator/advance.hpp> #include <boost/fusion/iterator/advance.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
@ -30,11 +29,11 @@ namespace boost { namespace fusion
template<typename Iterator, typename Dist> template<typename Iterator, typename Dist>
struct apply struct apply
{ {
typedef typename Iterator::first_type::iterator_type iterator_type; typedef typename Iterator::first_type iterator_type;
typedef typename Iterator::sequence_type sequence_type; typedef typename Iterator::sequence_type sequence_type;
typedef nview_iterator<sequence_type, typedef nview_iterator<sequence_type,
typename mpl::advance<iterator_type, Dist>::type> type; typename result_of::advance<iterator_type, Dist>::type> type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type static type

View File

@ -10,6 +10,7 @@
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp> #include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
@ -29,7 +30,7 @@ namespace boost { namespace fusion
typedef typename Sequence::sequence_type sequence_type; typedef typename Sequence::sequence_type sequence_type;
typedef typename Sequence::index_type index_type; typedef typename Sequence::index_type index_type;
typedef typename result_of::at<index_type, N>::type index; typedef typename result_of::value_at<index_type, N>::type index;
typedef typename result_of::at<sequence_type, index>::type type; typedef typename result_of::at<sequence_type, index>::type type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED

View File

@ -9,7 +9,6 @@
#define BOOST_FUSION_NVIEW_BEGIN_IMPL_SEP_23_2009_1036PM #define BOOST_FUSION_NVIEW_BEGIN_IMPL_SEP_23_2009_1036PM
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/mpl/begin.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
@ -32,8 +31,8 @@ namespace boost { namespace fusion
{ {
typedef typename Sequence::index_type index_type; typedef typename Sequence::index_type index_type;
typedef nview_iterator<Sequence, typedef nview_iterator<Sequence,
typename mpl::begin<index_type>::type> type; typename result_of::begin<index_type>::type> type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Sequence& s) static type call(Sequence& s)

View File

@ -17,10 +17,13 @@
#include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp> #include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/adapted/mpl/mpl_iterator.hpp>
#define BOOST_PP_ITERATION_PARAMS_1 \ #define BOOST_PP_ITERATION_PARAMS_1 \
(3, (1, FUSION_MAX_VECTOR_SIZE, \ (3, (1, FUSION_MAX_VECTOR_SIZE, \
"boost/fusion/view/nview/detail/cpp03/nview_impl.hpp")) \ "boost/fusion/view/nview/detail/cpp03/nview_impl.hpp")) \
/**/ /**/
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -9,8 +9,8 @@
#define BOOST_FUSION_NVIEW_DEREF_IMPL_SEP_24_2009_0818AM #define BOOST_FUSION_NVIEW_DEREF_IMPL_SEP_24_2009_0818AM
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/fusion/iterator/deref.hpp> #include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/container/vector.hpp> #include <boost/fusion/sequence/intrinsic/at.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
@ -30,7 +30,7 @@ namespace boost { namespace fusion
typedef typename Iterator::first_type first_type; typedef typename Iterator::first_type first_type;
typedef typename Iterator::sequence_type sequence_type; typedef typename Iterator::sequence_type sequence_type;
typedef typename result_of::deref<first_type>::type index; typedef typename result_of::value_of<first_type>::type index;
typedef typename result_of::at< typedef typename result_of::at<
typename sequence_type::sequence_type, index>::type type; typename sequence_type::sequence_type, index>::type type;

View File

@ -9,7 +9,6 @@
#define BOOST_FUSION_NVIEW_END_IMPL_SEP_24_2009_0140PM #define BOOST_FUSION_NVIEW_END_IMPL_SEP_24_2009_0140PM
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/mpl/end.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
@ -33,8 +32,8 @@ namespace boost { namespace fusion
{ {
typedef typename Sequence::index_type index_type; typedef typename Sequence::index_type index_type;
typedef nview_iterator<Sequence, typedef nview_iterator<Sequence,
typename mpl::end<index_type>::type> type; typename result_of::end<index_type>::type> type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Sequence& s) static type call(Sequence& s)

View File

@ -9,7 +9,7 @@
#define BOOST_FUSION_NVIEW_NEXT_IMPL_SEP_24_2009_0116PM #define BOOST_FUSION_NVIEW_NEXT_IMPL_SEP_24_2009_0116PM
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/mpl/next.hpp> #include <boost/fusion/iterator/next.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
@ -27,13 +27,13 @@ namespace boost { namespace fusion
struct next_impl<nview_iterator_tag> struct next_impl<nview_iterator_tag>
{ {
template <typename Iterator> template <typename Iterator>
struct apply struct apply
{ {
typedef typename Iterator::first_type::iterator_type first_type; typedef typename Iterator::first_type first_type;
typedef typename Iterator::sequence_type sequence_type; typedef typename Iterator::sequence_type sequence_type;
typedef nview_iterator<sequence_type, typedef nview_iterator<sequence_type,
typename mpl::next<first_type>::type> type; typename result_of::next<first_type>::type> type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type static type

View File

@ -8,11 +8,43 @@
#define BOOST_FUSION_NVIEW_IMPL_17122014_1948 #define BOOST_FUSION_NVIEW_IMPL_17122014_1948
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/fusion/container/vector/detail/config.hpp>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Without variadics, we will use the PP version // Without variadics, we will use the PP version
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR)
# include <boost/fusion/view/nview/detail/cpp03/nview_impl.hpp> # include <boost/fusion/view/nview/detail/cpp03/nview_impl.hpp>
#else
///////////////////////////////////////////////////////////////////////////////
// C++11 interface
///////////////////////////////////////////////////////////////////////////////
#include <boost/fusion/container/vector.hpp>
#include <boost/mpl/int.hpp>
namespace boost { namespace fusion
{
namespace result_of
{
template <typename Sequence, int ...I>
struct as_nview
{
typedef vector<mpl::int_<I>...> index_type;
typedef nview<Sequence, index_type> type;
};
}
template <int ...I, typename Sequence>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline nview<Sequence, vector<mpl::int_<I>...> >
as_nview(Sequence& s)
{
typedef vector<mpl::int_<I>...> index_type;
return nview<Sequence, index_type>(s);
}
}}
#endif #endif
#endif

View File

@ -9,7 +9,7 @@
#define BOOST_FUSION_NVIEW_PRIOR_IMPL_SEP_24_2009_0142PM #define BOOST_FUSION_NVIEW_PRIOR_IMPL_SEP_24_2009_0142PM
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/mpl/prior.hpp> #include <boost/fusion/iterator/prior.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
@ -27,13 +27,13 @@ namespace boost { namespace fusion
struct prior_impl<nview_iterator_tag> struct prior_impl<nview_iterator_tag>
{ {
template <typename Iterator> template <typename Iterator>
struct apply struct apply
{ {
typedef typename Iterator::first_type::iterator_type first_type; typedef typename Iterator::first_type first_type;
typedef typename Iterator::sequence_type sequence_type; typedef typename Iterator::sequence_type sequence_type;
typedef nview_iterator<sequence_type, typedef nview_iterator<sequence_type,
typename mpl::prior<first_type>::type> type; typename result_of::prior<first_type>::type> type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type static type

View File

@ -9,19 +9,15 @@
#define BOOST_FUSION_NVIEW_SEP_23_2009_0948PM #define BOOST_FUSION_NVIEW_SEP_23_2009_0948PM
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/add_reference.hpp> #include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/add_const.hpp> #include <boost/type_traits/add_const.hpp>
#include <boost/fusion/support/is_view.hpp> #include <boost/fusion/support/is_view.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/support/sequence_base.hpp> #include <boost/fusion/support/sequence_base.hpp>
#include <boost/fusion/container/vector.hpp> #include <boost/fusion/container/vector.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/view/transform_view.hpp> #include <boost/fusion/view/transform_view.hpp>
#include <boost/config.hpp> #include <boost/config.hpp>
@ -99,7 +95,7 @@ namespace boost { namespace fusion
typedef mpl::true_ is_view; typedef mpl::true_ is_view;
typedef Indicies index_type; typedef Indicies index_type;
typedef typename mpl::size<Indicies>::type size; typedef typename result_of::size<Indicies>::type size;
typedef typename mpl::if_< typedef typename mpl::if_<
is_const<Sequence>, detail::addconstref, detail::addref is_const<Sequence>, detail::addconstref, detail::addref

View File

@ -12,7 +12,6 @@
#include <boost/fusion/support/category_of.hpp> #include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/adapted/mpl/mpl_iterator.hpp>
#include <boost/fusion/view/nview/detail/size_impl.hpp> #include <boost/fusion/view/nview/detail/size_impl.hpp>
#include <boost/fusion/view/nview/detail/begin_impl.hpp> #include <boost/fusion/view/nview/detail/begin_impl.hpp>
@ -40,7 +39,7 @@ namespace boost { namespace fusion
typedef random_access_traversal_tag category; typedef random_access_traversal_tag category;
typedef Sequence sequence_type; typedef Sequence sequence_type;
typedef mpl_iterator<Pos> first_type; typedef Pos first_type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
explicit nview_iterator(Sequence& in_seq) explicit nview_iterator(Sequence& in_seq)