1 /*=============================================================================
2     Copyright (c) 2014-2015 Kohei Takahashi
3 
4     Distributed under the Boost Software License, Version 1.0. (See accompanying
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #ifndef FUSION_LIST_10262014_0537
8 #define FUSION_LIST_10262014_0537
9 
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/container/list/list_fwd.hpp>
12 
13 ///////////////////////////////////////////////////////////////////////////////
14 // Without variadics, we will use the PP version
15 ///////////////////////////////////////////////////////////////////////////////
16 #if !defined(BOOST_FUSION_HAS_VARIADIC_LIST)
17 # include <boost/fusion/container/list/detail/cpp03/list.hpp>
18 #else
19 
20 ///////////////////////////////////////////////////////////////////////////////
21 // C++11 interface
22 ///////////////////////////////////////////////////////////////////////////////
23 #include <utility>
24 #include <boost/fusion/container/list/detail/list_to_cons.hpp>
25 
26 namespace boost { namespace fusion
27 {
28     struct nil_;
29 
30     template <>
31     struct list<>
32         : detail::list_to_cons<>::type
33     {
34     private:
35         typedef detail::list_to_cons<> list_to_cons;
36         typedef list_to_cons::type inherited_type;
37 
38     public:
39         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
listboost::fusion::list40         list()
41             : inherited_type() {}
42 
43 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
44         template <typename Sequence>
45         BOOST_FUSION_GPU_ENABLED
listboost::fusion::list46         list(Sequence const& rhs)
47             : inherited_type(rhs) {}
48 
49         template <typename Sequence>
50         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
51         list&
operator =boost::fusion::list52         operator=(Sequence const& rhs)
53         {
54             inherited_type::operator=(rhs);
55             return *this;
56         }
57 #else
58         template <typename Sequence>
59         BOOST_FUSION_GPU_ENABLED
listboost::fusion::list60         list(Sequence&& rhs)
61             : inherited_type(std::forward<Sequence>(rhs)) {}
62 
63         template <typename Sequence>
64         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
65         list&
operator =boost::fusion::list66         operator=(Sequence&& rhs)
67         {
68             inherited_type::operator=(std::forward<Sequence>(rhs));
69             return *this;
70         }
71 #endif
72     };
73 
74     template <typename ...T>
75     struct list
76         : detail::list_to_cons<T...>::type
77     {
78     private:
79         typedef detail::list_to_cons<T...> list_to_cons;
80         typedef typename list_to_cons::type inherited_type;
81 
82     public:
83         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
listboost::fusion::list84         list()
85             : inherited_type() {}
86 
87 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
88         template <typename Sequence>
89         BOOST_FUSION_GPU_ENABLED
listboost::fusion::list90         list(Sequence const& rhs)
91             : inherited_type(rhs) {}
92 #else
93         template <typename Sequence>
94         BOOST_FUSION_GPU_ENABLED
listboost::fusion::list95         list(Sequence&& rhs)
96             : inherited_type(std::forward<Sequence>(rhs)) {}
97 #endif
98 
99         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
100         explicit
listboost::fusion::list101         list(typename detail::call_param<T>::type ...args)
102             : inherited_type(list_to_cons::call(args...)) {}
103 
104 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
105         template <typename Sequence>
106         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
107         list&
operator =boost::fusion::list108         operator=(Sequence const& rhs)
109         {
110             inherited_type::operator=(rhs);
111             return *this;
112         }
113 #else
114         template <typename Sequence>
115         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
116         list&
operator =boost::fusion::list117         operator=(Sequence&& rhs)
118         {
119             inherited_type::operator=(std::forward<Sequence>(rhs));
120             return *this;
121         }
122 #endif
123     };
124 }}
125 
126 #endif
127 #endif
128