Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2001-2011 Joel de Guzman
|
Chris@16
|
3
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 ==============================================================================*/
|
Chris@16
|
7 #if !defined(FUSION_PUSH_FRONT_07162005_0749)
|
Chris@16
|
8 #define FUSION_PUSH_FRONT_07162005_0749
|
Chris@16
|
9
|
Chris@16
|
10 #include <boost/fusion/support/detail/as_fusion_element.hpp>
|
Chris@16
|
11 #include <boost/fusion/view/joint_view/joint_view.hpp>
|
Chris@16
|
12 #include <boost/fusion/view/single_view/single_view.hpp>
|
Chris@16
|
13 #include <boost/fusion/support/is_sequence.hpp>
|
Chris@16
|
14 #include <boost/utility/enable_if.hpp>
|
Chris@16
|
15
|
Chris@16
|
16 namespace boost { namespace fusion
|
Chris@16
|
17 {
|
Chris@16
|
18 namespace result_of
|
Chris@16
|
19 {
|
Chris@16
|
20 template <typename Sequence, typename T>
|
Chris@16
|
21 struct push_front
|
Chris@16
|
22 {
|
Chris@16
|
23 typedef fusion::single_view<typename detail::as_fusion_element<T>::type> single_view;
|
Chris@16
|
24 typedef joint_view<single_view const, Sequence> type;
|
Chris@16
|
25 };
|
Chris@16
|
26 }
|
Chris@16
|
27
|
Chris@16
|
28 template <typename Sequence, typename T>
|
Chris@16
|
29 inline
|
Chris@16
|
30 typename
|
Chris@16
|
31 lazy_enable_if<
|
Chris@16
|
32 traits::is_sequence<Sequence>
|
Chris@16
|
33 , result_of::push_front<Sequence const, T>
|
Chris@16
|
34 >::type
|
Chris@16
|
35 push_front(Sequence const& seq, T const& x)
|
Chris@16
|
36 {
|
Chris@16
|
37 typedef typename result_of::push_front<Sequence const, T> push_front;
|
Chris@16
|
38 typedef typename push_front::single_view single_view;
|
Chris@16
|
39 typedef typename push_front::type result;
|
Chris@16
|
40 single_view x_(x);
|
Chris@16
|
41 return result(x_, seq);
|
Chris@16
|
42 }
|
Chris@16
|
43 }}
|
Chris@16
|
44
|
Chris@16
|
45 #endif
|
Chris@16
|
46
|