Implement C++11 Variadic Templates based list.

This commit is contained in:
Kohei Takahashi
2014-11-09 15:26:28 +09:00
parent 2b14951660
commit 275f65f9ad
4 changed files with 201 additions and 0 deletions

View File

@@ -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