mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-23 17:17:23 +02:00
Implement C++11 Variadic Templates based list.
This commit is contained in:
@ -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<T...> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename ...T>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
inline list<typename detail::as_fusion_element<T>::type...>
|
||||
make_list(T const&... arg)
|
||||
{
|
||||
return list<typename detail::as_fusion_element<T>::type...>(arg...);
|
||||
}
|
||||
}}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -13,6 +13,61 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename ...T>
|
||||
struct list_to_cons;
|
||||
|
||||
template <>
|
||||
struct list_to_cons<>
|
||||
{
|
||||
typedef nil_ type;
|
||||
};
|
||||
|
||||
template <typename Head>
|
||||
struct list_to_cons<Head>
|
||||
{
|
||||
typedef Head head_type;
|
||||
typedef list_to_cons<> tail_list_to_cons;
|
||||
typedef typename tail_list_to_cons::type tail_type;
|
||||
|
||||
typedef cons<head_type, tail_type> type;
|
||||
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
static type
|
||||
call(typename detail::call_param<Head>::type _h)
|
||||
{
|
||||
return type(_h);
|
||||
}
|
||||
};
|
||||
|
||||
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_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
|
||||
|
@ -13,6 +13,97 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <boost/fusion/container/list/detail/list_to_cons.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct nil_;
|
||||
struct void_;
|
||||
|
||||
template <>
|
||||
struct list<>
|
||||
: detail::list_to_cons<>::type
|
||||
{
|
||||
private:
|
||||
typedef detail::list_to_cons<> list_to_cons;
|
||||
|
||||
public:
|
||||
typedef list_to_cons::type inherited_type;
|
||||
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list()
|
||||
: inherited_type() {}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list(Sequence const& rhs)
|
||||
: inherited_type(rhs) {}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list&
|
||||
operator=(Sequence const& rhs)
|
||||
{
|
||||
inherited_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ...T>
|
||||
struct list
|
||||
: detail::list_to_cons<T...>::type
|
||||
{
|
||||
private:
|
||||
typedef detail::list_to_cons<T...> list_to_cons;
|
||||
|
||||
public:
|
||||
typedef typename list_to_cons::type inherited_type;
|
||||
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list()
|
||||
: inherited_type() {}
|
||||
|
||||
template <typename ...U>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list(list<U...> const& rhs)
|
||||
: inherited_type(rhs) {}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list(Sequence const& rhs)
|
||||
: inherited_type(rhs) {}
|
||||
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
explicit
|
||||
list(typename detail::call_param<T>::type ...args)
|
||||
: inherited_type(list_to_cons::call(args...)) {}
|
||||
|
||||
template <typename ...U>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list&
|
||||
operator=(list<U...> const& rhs)
|
||||
{
|
||||
inherited_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
list&
|
||||
operator=(Sequence const& rhs)
|
||||
{
|
||||
inherited_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}}
|
||||
|
||||
#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
|
||||
|
Reference in New Issue
Block a user