Merge pull request #84 from Flast/feature/variadic/list
Variadic fusion::list.
This commit is contained in:
commit
00823cc315
@ -53,7 +53,7 @@ namespace boost { namespace fusion
|
||||
// $$$ shouldn't we remove_reference first to allow references? $$$
|
||||
#define BOOST_FUSION_REF(z, n, data) BOOST_PP_CAT(T, n)&
|
||||
|
||||
#define BOOST_PP_FILENAME_1 <boost/fusion/container/generation/detail/list_tie.hpp>
|
||||
#define BOOST_PP_FILENAME_1 <boost/fusion/container/generation/detail/pp_list_tie.hpp>
|
||||
#define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_LIST_SIZE)
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
|
@ -10,7 +10,35 @@
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
|
||||
#if !defined(BOOST_FUSION_HAS_VARIADIC_LIST)
|
||||
# include <boost/fusion/container/generation/detail/pp_list_tie.hpp>
|
||||
#else
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 variadic interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename ...T>
|
||||
struct list_tie
|
||||
{
|
||||
typedef list<T&...> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename ...T>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline list<T&...>
|
||||
list_tie(T&... arg)
|
||||
{
|
||||
return list<T&...>(arg...);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -10,7 +10,37 @@
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
|
||||
#if !defined(BOOST_FUSION_HAS_VARIADIC_LIST)
|
||||
# include <boost/fusion/container/generation/detail/pp_make_list.hpp>
|
||||
#else
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 variadic interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/fusion/support/detail/as_fusion_element.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename ...T>
|
||||
struct make_list
|
||||
{
|
||||
typedef list<typename detail::as_fusion_element<T>::type...> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename ...T>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline typename result_of::make_list<T...>::type
|
||||
make_list(T const&... arg)
|
||||
{
|
||||
return typename result_of::make_list<T...>::type(arg...);
|
||||
}
|
||||
}}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -46,10 +46,9 @@ namespace boost { namespace fusion
|
||||
typedef
|
||||
detail::list_to_cons<BOOST_PP_ENUM_PARAMS(FUSION_MAX_LIST_SIZE, T)>
|
||||
list_to_cons;
|
||||
|
||||
public:
|
||||
typedef typename list_to_cons::type inherited_type;
|
||||
|
||||
public:
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list()
|
||||
: inherited_type() {}
|
||||
|
@ -18,8 +18,8 @@ namespace boost { namespace fusion
|
||||
typedef
|
||||
detail::list_to_cons<T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9>
|
||||
list_to_cons;
|
||||
public:
|
||||
typedef typename list_to_cons::type inherited_type;
|
||||
public:
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list()
|
||||
: inherited_type() {}
|
||||
|
@ -18,8 +18,8 @@ namespace boost { namespace fusion
|
||||
typedef
|
||||
detail::list_to_cons<T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19>
|
||||
list_to_cons;
|
||||
public:
|
||||
typedef typename list_to_cons::type inherited_type;
|
||||
public:
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list()
|
||||
: inherited_type() {}
|
||||
|
@ -18,8 +18,8 @@ namespace boost { namespace fusion
|
||||
typedef
|
||||
detail::list_to_cons<T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 , T22 , T23 , T24 , T25 , T26 , T27 , T28 , T29>
|
||||
list_to_cons;
|
||||
public:
|
||||
typedef typename list_to_cons::type inherited_type;
|
||||
public:
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list()
|
||||
: inherited_type() {}
|
||||
|
@ -18,8 +18,8 @@ namespace boost { namespace fusion
|
||||
typedef
|
||||
detail::list_to_cons<T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 , T22 , T23 , T24 , T25 , T26 , T27 , T28 , T29 , T30 , T31 , T32 , T33 , T34 , T35 , T36 , T37 , T38 , T39>
|
||||
list_to_cons;
|
||||
public:
|
||||
typedef typename list_to_cons::type inherited_type;
|
||||
public:
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list()
|
||||
: inherited_type() {}
|
||||
|
@ -18,8 +18,8 @@ namespace boost { namespace fusion
|
||||
typedef
|
||||
detail::list_to_cons<T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 , T22 , T23 , T24 , T25 , T26 , T27 , T28 , T29 , T30 , T31 , T32 , T33 , T34 , T35 , T36 , T37 , T38 , T39 , T40 , T41 , T42 , T43 , T44 , T45 , T46 , T47 , T48 , T49>
|
||||
list_to_cons;
|
||||
public:
|
||||
typedef typename list_to_cons::type inherited_type;
|
||||
public:
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list()
|
||||
: inherited_type() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Kohei Takahashi
|
||||
Copyright (c) 2014-2015 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,12 +7,55 @@
|
||||
#ifndef FUSION_LIST_MAIN_10262014_0447
|
||||
#define FUSION_LIST_MAIN_10262014_0447
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/container/list/list_fwd.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Without variadics, we will use the PP version
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(BOOST_FUSION_HAS_VARIADIC_LIST)
|
||||
# include <boost/fusion/container/list/detail/cpp03/list_to_cons.hpp>
|
||||
#else
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/fusion/container/list/cons.hpp>
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename ...T>
|
||||
struct list_to_cons;
|
||||
|
||||
template <>
|
||||
struct list_to_cons<>
|
||||
{
|
||||
typedef nil_ type;
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
static type call() { return type(); }
|
||||
};
|
||||
|
||||
template <typename Head, typename ...Tail>
|
||||
struct list_to_cons<Head, Tail...>
|
||||
{
|
||||
typedef Head head_type;
|
||||
typedef list_to_cons<Tail...> tail_list_to_cons;
|
||||
typedef typename tail_list_to_cons::type tail_type;
|
||||
|
||||
typedef cons<head_type, tail_type> type;
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
static type
|
||||
call(typename detail::call_param<Head>::type _h,
|
||||
typename detail::call_param<Tail>::type ..._t)
|
||||
{
|
||||
return type(_h, tail_list_to_cons::call(_t...));
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Kohei Takahashi
|
||||
Copyright (c) 2014-2015 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)
|
||||
@ -13,6 +13,115 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Without variadics, we will use the PP version
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(BOOST_FUSION_HAS_VARIADIC_LIST)
|
||||
# include <boost/fusion/container/list/detail/cpp03/list.hpp>
|
||||
#else
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <utility>
|
||||
#include <boost/fusion/container/list/detail/list_to_cons.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct nil_;
|
||||
|
||||
template <>
|
||||
struct list<>
|
||||
: detail::list_to_cons<>::type
|
||||
{
|
||||
private:
|
||||
typedef detail::list_to_cons<> list_to_cons;
|
||||
typedef list_to_cons::type inherited_type;
|
||||
|
||||
public:
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list()
|
||||
: inherited_type() {}
|
||||
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template <typename Sequence>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list(Sequence const& rhs)
|
||||
: inherited_type(rhs) {}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list&
|
||||
operator=(Sequence const& rhs)
|
||||
{
|
||||
inherited_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
template <typename Sequence>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list(Sequence&& rhs)
|
||||
: inherited_type(std::forward<Sequence>(rhs)) {}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list&
|
||||
operator=(Sequence&& rhs)
|
||||
{
|
||||
inherited_type::operator=(std::forward<Sequence>(rhs));
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <typename ...T>
|
||||
struct list
|
||||
: detail::list_to_cons<T...>::type
|
||||
{
|
||||
private:
|
||||
typedef detail::list_to_cons<T...> list_to_cons;
|
||||
typedef typename list_to_cons::type inherited_type;
|
||||
|
||||
public:
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list()
|
||||
: inherited_type() {}
|
||||
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template <typename Sequence>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list(Sequence const& rhs)
|
||||
: inherited_type(rhs) {}
|
||||
#else
|
||||
template <typename Sequence>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list(Sequence&& rhs)
|
||||
: inherited_type(std::forward<Sequence>(rhs)) {}
|
||||
#endif
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
explicit
|
||||
list(typename detail::call_param<T>::type ...args)
|
||||
: inherited_type(list_to_cons::call(args...)) {}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template <typename Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list&
|
||||
operator=(Sequence const& rhs)
|
||||
{
|
||||
inherited_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
template <typename Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
list&
|
||||
operator=(Sequence&& rhs)
|
||||
{
|
||||
inherited_type::operator=(std::forward<Sequence>(rhs));
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -10,9 +10,34 @@
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \
|
||||
|| (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
|
||||
# if defined(BOOST_FUSION_HAS_VARIADIC_LIST)
|
||||
# undef BOOST_FUSION_HAS_VARIADIC_LIST
|
||||
# endif
|
||||
#else
|
||||
# if !defined(BOOST_FUSION_HAS_VARIADIC_LIST)
|
||||
# define BOOST_FUSION_HAS_VARIADIC_LIST
|
||||
# endif
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// With no variadics, we will use the C++03 version
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(BOOST_FUSION_HAS_VARIADIC_LIST)
|
||||
# include <boost/fusion/container/list/detail/cpp03/list_fwd.hpp>
|
||||
#else
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
|
||||
template <typename ...T>
|
||||
struct list;
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user