Lely core libraries 2.3.4
utility.hpp
Go to the documentation of this file.
1
22#ifndef LELY_LIBC_UTILITY_HPP_
23#define LELY_LIBC_UTILITY_HPP_
24
25#include <lely/features.h>
26
27#include <utility>
28
29namespace lely {
30namespace compat {
31
32#if __cplusplus >= 201402L
33
34using ::std::index_sequence;
35using ::std::index_sequence_for;
36using ::std::integer_sequence;
37using ::std::make_index_sequence;
38using ::std::make_integer_sequence;
39
40#else // __cplusplus < 201402L
41
43template <typename T, T... Ints>
45 typedef T value_type;
46
47 static constexpr ::std::size_t
48 size() noexcept {
49 return sizeof...(Ints);
50 }
51};
52
53namespace detail {
54
55template <::std::size_t...>
56struct index_tuple {};
57
58template <class, class>
60
61template <::std::size_t... I1, ::std::size_t... I2>
63 using type = index_tuple<I1..., (I2 + sizeof...(I1))...>;
64};
65
66template <::std::size_t N>
68 : index_tuple_cat<typename make_index_tuple<N / 2>::type,
69 typename make_index_tuple<N - N / 2>::type> {};
70
71template <>
73 typedef index_tuple<0> type;
74};
75
76template <>
78 typedef index_tuple<> type;
79};
80
83
84template <typename T, T N, ::std::size_t... Ints>
86 static_assert(N >= 0, "Cannot make integer sequence of negative length");
87
89};
90
91} // namespace detail
92
97template <::std::size_t... Ints>
98using index_sequence = integer_sequence<::std::size_t, Ints...>;
99
104template <typename T, T N>
107
112template <::std::size_t N>
114
119template <typename... T>
121
122#endif // __cplusplus < 201402L
123
124} // namespace compat
125} // namespace lely
126
127#endif // !LELY_LIBC_UTILITY_HPP_
A CANopen value.
Definition val.hpp:42
This header file is part of the Lely libraries; it contains the compiler feature definitions.
A compile-time sequence of integers.
Definition utility.hpp:44
typename detail::make_integer_sequence< T, N >::type make_integer_sequence
A helper alias template to simplify the creation of lely::compat::integer_sequence types with 0,...
Definition utility.hpp:106