tinympl  0.2
mini MPL library for C++11
join.hpp
1 // Copyright (C) 2013, Ennio Barbaro.
2 //
3 // Use, modification, and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // See http://sbabbi.github.io/tinympl for documentation.
8 //
9 // You are welcome to contact the author at:
10 // enniobarbaro@gmail.com
11 //
12 
13 #ifndef TINYMPL_JOIN_HPP
14 #define TINYMPL_JOIN_HPP
15 
16 #include <tinympl/sequence.hpp>
17 #include <tinympl/as_sequence.hpp>
18 
19 namespace tinympl {
20 
29 template<class ... Args> struct join;
30 
31 template<class Head, class Next, class ... Tail>
32 struct join<Head, Next, Tail...> {
33  typedef
34  typename join < typename join<Head, Next>::type, Tail... >::type type;
35 };
36 
37 template<class Head, class Last> struct join<Head, Last> {
38 private:
39  template<class S1, class S2, template<class ...> class Out> struct do_join;
40 
41  template<class ... S1, class ... S2, template<class ...> class Out>
42  struct do_join< sequence<S1...>, sequence<S2...>, Out > {
43  typedef Out<S1..., S2...> type;
44  };
45 
46 public:
47  typedef typename do_join <
48  as_sequence_t<Head>,
49  as_sequence_t<Last>,
50  as_sequence<Head>::template rebind >::type type;
51 };
52 
53 template<class Head> struct join<Head> {
54  typedef Head type;
55 };
56 
57 } // namespace tinympl
58 
59 #endif // TINYMPL_JOIN_HPP
Merge two sequences.
Definition: join.hpp:29
The main sequence type.
Definition: sequence.hpp:28