| 1 | /*============================================================================= |
| 2 | Copyright (c) 2001-2011 Joel de Guzman |
| 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 | #if !defined(FUSION_BUILD_CONS_09232005_1222) |
| 8 | #define FUSION_BUILD_CONS_09232005_1222 |
| 9 | |
| 10 | #include <boost/fusion/support/config.hpp> |
| 11 | #include <boost/fusion/container/list/cons.hpp> |
| 12 | #include <boost/fusion/iterator/equal_to.hpp> |
| 13 | #include <boost/fusion/iterator/next.hpp> |
| 14 | #include <boost/fusion/iterator/value_of.hpp> |
| 15 | #include <boost/fusion/iterator/deref.hpp> |
| 16 | |
| 17 | namespace boost { namespace fusion { namespace detail |
| 18 | { |
| 19 | template < |
| 20 | typename First |
| 21 | , typename Last |
| 22 | , bool is_empty = result_of::equal_to<First, Last>::value> |
| 23 | struct build_cons; |
| 24 | |
| 25 | template <typename First, typename Last> |
| 26 | struct build_cons<First, Last, true> |
| 27 | { |
| 28 | typedef nil_ type; |
| 29 | |
| 30 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
| 31 | static nil_ |
| 32 | call(First const&, Last const&) |
| 33 | { |
| 34 | return nil_(); |
| 35 | } |
| 36 | }; |
| 37 | |
| 38 | template <typename First, typename Last> |
| 39 | struct build_cons<First, Last, false> |
| 40 | { |
| 41 | typedef |
| 42 | build_cons<typename result_of::next<First>::type, Last> |
| 43 | next_build_cons; |
| 44 | |
| 45 | typedef cons< |
| 46 | typename result_of::value_of<First>::type |
| 47 | , typename next_build_cons::type> |
| 48 | type; |
| 49 | |
| 50 | BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
| 51 | static type |
| 52 | call(First const& f, Last const& l) |
| 53 | { |
| 54 | typename result_of::value_of<First>::type v = *f; |
| 55 | return type(v, next_build_cons::call(fusion::next(f), l)); |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | }}} |
| 60 | |
| 61 | #endif |
| 62 | |