summaryrefslogtreecommitdiff
path: root/src/bindings/eina_cxx/eina_integer_sequence.hh
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-05-23 12:01:30 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-05-23 15:05:50 -0300
commite3c8b280c639058c54f5576f189d0dc288105fc7 (patch)
treee313fa05bd9d2b2cb88623f6adea2c3b396b66e8 /src/bindings/eina_cxx/eina_integer_sequence.hh
parent930f39b91b12b311f40cd96b4cf2e85085b01832 (diff)
c++: Reorganized C++ binding generation
Moved all generation to a single Makefile_Cxx.am file instead of throughout the whole project. And fixed C++ generation on Elementary after elm merge.
Diffstat (limited to 'src/bindings/eina_cxx/eina_integer_sequence.hh')
-rw-r--r--src/bindings/eina_cxx/eina_integer_sequence.hh115
1 files changed, 0 insertions, 115 deletions
diff --git a/src/bindings/eina_cxx/eina_integer_sequence.hh b/src/bindings/eina_cxx/eina_integer_sequence.hh
deleted file mode 100644
index f99c871..0000000
--- a/src/bindings/eina_cxx/eina_integer_sequence.hh
+++ /dev/null
@@ -1,115 +0,0 @@
1#ifndef EINA_CXX_EINA_INTEGER_SEQUENCE_HH
2#define EINA_CXX_EINA_INTEGER_SEQUENCE_HH
3
4#include <cstdlib>
5
6/**
7 * @addtogroup Eina_Cxx_Data_Types_Group
8 *
9 * @{
10 */
11
12namespace efl { namespace eina {
13
14/**
15 * @defgroup Eina_Cxx_Integer_Sequence_Group Integer Sequence
16 * @ingroup Eina_Cxx_Data_Types_Group
17 *
18 * @{
19 */
20
21/**
22 * Compile-time sequence of integers.
23 */
24template <typename T, T... Ints>
25struct integer_sequence
26{
27 typedef T value_type; /**< Type of the integers. */
28
29 /**
30 * @brief Get the number of elements in the sequence.
31 * @return <tt>std::size_t</tt> representing the sequence size.
32 */
33 static constexpr std::size_t size() { return sizeof...(Ints); }
34 typedef integer_sequence<T, Ints...> type; /**< Type for the sequence instantiation. */
35};
36
37template<class S1, class S2> struct concat;
38
39/**
40 * Compile-time concatenation of two integer sequences.
41 */
42template<typename T, T... I1, T... I2>
43struct concat<integer_sequence<T, I1...>, integer_sequence<T, I2...> >
44 : integer_sequence<T, I1..., (sizeof...(I1)+I2)...> {};
45
46template<class S1, class S2>
47using Concat = typename concat<S1, S2>::type;
48
49template<typename T, T N> struct gen_seq;
50
51/**
52 * Make a compile time sequence of integers from @c 0 to <tt>N-1</tt>.
53 */
54template<typename T, T N> using make_integer_sequence = typename gen_seq<T, N>::type;
55
56template<typename T, T N>
57struct gen_seq : Concat<make_integer_sequence<T, N/2>
58 , make_integer_sequence<T, N - N/2>>{};
59
60template<> struct gen_seq<std::size_t, 0> : integer_sequence<std::size_t>{};
61template<> struct gen_seq<std::size_t, 1> : integer_sequence<std::size_t, 0>{};
62
63/**
64 * Compile time sequence of indexes.
65 */
66template <std::size_t... I>
67using index_sequence = integer_sequence<std::size_t, I...>;
68
69/**
70 * Make a compile time sequence of indexes from @c 0 to <tt>N-1</tt>.
71 */
72template <std::size_t I>
73using make_index_sequence = make_integer_sequence<std::size_t, I>;
74
75template <typename T, typename U>
76struct pop_integer_sequence_t;
77
78template <typename T>
79struct pop_integer_sequence_t<integer_sequence<T>, integer_sequence<T> >
80{
81 typedef integer_sequence<T> type;
82};
83
84template <typename T, T S0, T... S>
85struct pop_integer_sequence_t<integer_sequence<T>, integer_sequence<T, S0, S...> >
86{
87 typedef integer_sequence<T, S...> type;
88};
89
90template <typename T, T S0, T... S>
91struct pop_integer_sequence_t<integer_sequence<T, S0, S...>, integer_sequence<T> >
92{
93 typedef integer_sequence<T> type;
94};
95
96template <typename T, T S, T... Ss1, T... Ss2>
97struct pop_integer_sequence_t<integer_sequence<T, S, Ss1...>, integer_sequence<T, S, Ss2...> >
98 : pop_integer_sequence_t<integer_sequence<T, Ss1...>, integer_sequence<T, Ss2...> >
99{
100};
101
102template <typename T, typename U>
103using pop_integer_sequence = typename pop_integer_sequence_t<T, U>::type;
104
105/**
106 * @}
107 */
108
109} }
110
111/**
112 * @}
113 */
114
115#endif