45 inline constexpr
int signum(T x, std::false_type is_signed)
51 inline constexpr
int signum(T x, std::true_type is_signed)
53 return (T(0) < x) - (x < T(0));
59 return signum(x, std::is_signed<T>());
62 #if __cplusplus <= 201103L 76 _x = fmod(_x, 2 * M_PI);
77 _x = fmod(_x + 2 * M_PI, 2 * M_PI);
86 template <
typename Enumeration>
87 constexpr
auto asInt(Enumeration
const value) ->
typename std::underlying_type<Enumeration>::type
89 return static_cast<typename std::underlying_type<Enumeration>::type
>(
value);
92 template <std::
intmax_t Num, std::
intmax_t Denom = 1>
95 static constexpr
const std::intmax_t
num = Num;
96 static constexpr
const std::intmax_t
denom = Denom;
97 static constexpr
const double val = (Num) / (
const double)(Denom);
100 template <std::size_t II = 0,
class FuncT,
typename... Tp>
101 constexpr
inline typename std::enable_if<II ==
sizeof...(Tp),
void>::type
for_each_tuple(std::tuple<Tp...>&, FuncT)
105 template <std::size_t II = 0,
class FuncT,
typename... Tp>
106 constexpr
inline typename std::enable_if <
107 II<
sizeof...(Tp),
void>::type
for_each_tuple(std::tuple<Tp...>& t, FuncT f)
112 template <std::size_t II = 0,
class FuncT,
typename... Tp>
113 constexpr
inline typename std::enable_if<II ==
sizeof...(Tp),
void>::type
for_each_tuple(
const std::tuple<Tp...>&,
118 template <std::size_t II = 0,
class FuncT,
typename... Tp>
119 constexpr
inline typename std::enable_if <
120 II<
sizeof...(Tp),
void>::type
for_each_tuple(
const std::tuple<Tp...>& t, FuncT f)
126 template <std::size_t II = 0,
class FuncT,
typename... Tp>
127 constexpr
inline typename std::enable_if<II ==
sizeof...(Tp),
void>::type for_each_2_tuples(
const std::tuple<Tp...>&,
128 std::tuple<Tp...>&, FuncT)
132 template <std::size_t II = 0,
class FuncT,
typename... Tp>
133 constexpr
inline typename std::enable_if <
134 II<
sizeof...(Tp),
void>::type for_each_2_tuples(
const std::tuple<Tp...>& t1, std::tuple<Tp...>& t2, FuncT f)
136 f(std::get<II>(t1), std::get<II>(t2));
137 for_each_2_tuples<II + 1, FuncT, Tp...>(t1, t2, f);
140 template <std::size_t II = 0,
typename ArrayType,
typename... Tp>
141 inline typename std::enable_if<II ==
sizeof...(Tp),
void>::type store_tuple_ptr_to_array(std::tuple<Tp...>&, ArrayType&)
145 template <std::size_t II = 0,
typename ArrayType,
typename... Tp>
146 inline typename std::enable_if <
147 II<
sizeof...(Tp),
void>::type store_tuple_ptr_to_array(std::tuple<Tp...>& t, ArrayType& _array)
149 _array[II] = &std::get<II>(t);
153 template <
class T,
class Tuple>
154 struct Get_Tuple_Index;
155 template <
class T,
class... Types>
156 struct Get_Tuple_Index<T, std::tuple<T, Types...>>
158 static const std::size_t
value = 0;
160 template <
class T,
class U,
class... Types>
161 struct Get_Tuple_Index<T, std::tuple<U, Types...>>
163 static const std::size_t
value = 1 + Get_Tuple_Index<T, std::tuple<Types...>>
::value;
191 #if __cplusplus <= 201103L 195 template <
typename T,
typename... Args>
198 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
202 template <
class T, std::size_t N,
class... Args>
203 struct get_number_of_element_from_tuple_by_type_impl
208 template <
class T, std::size_t N,
class... Args>
209 struct get_number_of_element_from_tuple_by_type_impl<T, N, T, Args...>
211 static constexpr
auto value = N;
214 template <
class T, std::size_t N,
class U,
class... Args>
215 struct get_number_of_element_from_tuple_by_type_impl<T, N, U, Args...>
217 static constexpr
auto value = get_number_of_element_from_tuple_by_type_impl<T, N + 1, Args...>
::value;
221 template <
class T,
class... Args>
222 T&
get(std::tuple<Args...>& t)
224 return std::get<get_number_of_element_from_tuple_by_type_impl<T, 0, Args...>
::value>(t);
227 #endif // __cplusplus <= 201103L static constexpr const double val
Helper function needed to upgrade c++ 2011.
constexpr auto asInt(Enumeration const value) -> typename std::underlying_type< Enumeration >::type
std::unique_ptr< T > make_unique(Args &&...args)
constexpr std::enable_if< II==sizeof...(Tp), void >::type for_each_tuple(std::tuple< Tp... > &, FuncT)
T & get(std::tuple< Args... > &t)
static constexpr auto value
constexpr int signum(T x, std::false_type is_signed)
static constexpr const std::intmax_t denom
static constexpr const std::intmax_t num