diff --git a/include/boost/fusion/container/generation/make_list.hpp b/include/boost/fusion/container/generation/make_list.hpp index 0aafb272..fbe93979 100644 --- a/include/boost/fusion/container/generation/make_list.hpp +++ b/include/boost/fusion/container/generation/make_list.hpp @@ -10,7 +10,37 @@ #include #include +#if !defined(BOOST_FUSION_HAS_VARIADIC_LIST) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct make_list + { + typedef list type; + }; + } + + template + BOOST_FUSION_GPU_ENABLED + inline list::type...> + make_list(T const&... arg) + { + return list::type...>(arg...); + } + }} + #endif +#endif diff --git a/include/boost/fusion/container/list/detail/list_to_cons.hpp b/include/boost/fusion/container/list/detail/list_to_cons.hpp index e967c892..780d637e 100644 --- a/include/boost/fusion/container/list/detail/list_to_cons.hpp +++ b/include/boost/fusion/container/list/detail/list_to_cons.hpp @@ -13,6 +13,61 @@ /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_LIST) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include + +namespace boost { namespace fusion { namespace detail +{ + template + struct list_to_cons; + + template <> + struct list_to_cons<> + { + typedef nil_ type; + }; + + template + struct list_to_cons + { + typedef Head head_type; + typedef list_to_cons<> tail_list_to_cons; + typedef typename tail_list_to_cons::type tail_type; + + typedef cons type; + + BOOST_FUSION_GPU_ENABLED + static type + call(typename detail::call_param::type _h) + { + return type(_h); + } + }; + + template + struct list_to_cons + { + typedef Head head_type; + typedef list_to_cons tail_list_to_cons; + typedef typename tail_list_to_cons::type tail_type; + + typedef cons type; + + BOOST_FUSION_GPU_ENABLED + static type + call(typename detail::call_param::type _h, + typename detail::call_param::type ..._t) + { + return type(_h, tail_list_to_cons::call(_t...)); + } + }; +}}} #endif +#endif diff --git a/include/boost/fusion/container/list/list.hpp b/include/boost/fusion/container/list/list.hpp index b07f0fc9..ebf8b03d 100644 --- a/include/boost/fusion/container/list/list.hpp +++ b/include/boost/fusion/container/list/list.hpp @@ -13,6 +13,97 @@ /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_LIST) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include + +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 + BOOST_FUSION_GPU_ENABLED + list(Sequence const& rhs) + : inherited_type(rhs) {} + + template + BOOST_FUSION_GPU_ENABLED + list& + operator=(Sequence const& rhs) + { + inherited_type::operator=(rhs); + return *this; + } + }; + + template + struct list + : detail::list_to_cons::type + { + private: + typedef detail::list_to_cons list_to_cons; + + public: + typedef typename list_to_cons::type inherited_type; + + BOOST_FUSION_GPU_ENABLED + list() + : inherited_type() {} + + template + BOOST_FUSION_GPU_ENABLED + list(list const& rhs) + : inherited_type(rhs) {} + + template + BOOST_FUSION_GPU_ENABLED + list(Sequence const& rhs) + : inherited_type(rhs) {} + + BOOST_FUSION_GPU_ENABLED + explicit + list(typename detail::call_param::type ...args) + : inherited_type(list_to_cons::call(args...)) {} + + template + BOOST_FUSION_GPU_ENABLED + list& + operator=(list const& rhs) + { + inherited_type::operator=(rhs); + return *this; + } + + template + BOOST_FUSION_GPU_ENABLED + list& + operator=(Sequence const& rhs) + { + inherited_type::operator=(rhs); + return *this; + } + }; +}} #endif +#endif diff --git a/include/boost/fusion/container/list/list_fwd.hpp b/include/boost/fusion/container/list/list_fwd.hpp index d7ea0dcd..c5f26192 100644 --- a/include/boost/fusion/container/list/list_fwd.hpp +++ b/include/boost/fusion/container/list/list_fwd.hpp @@ -10,9 +10,34 @@ #include #include +#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 +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + struct void_; + + template + struct list; +}} #endif +#endif