Tatooine
utility.h
Go to the documentation of this file.
1#ifndef TATOOINE_GL_UTILITY_H
2#define TATOOINE_GL_UTILITY_H
3//==============================================================================
4#include <array>
5#include <concepts>
6#include <utility>
8#include <tatooine/vec.h>
9//==============================================================================
10namespace tatooine::gl {
11//==============================================================================
12template <typename T>
14template <typename T>
15static constexpr auto value_type_v = value_type<T>::value;
16template <typename T, size_t N>
17struct value_type<std::array<T, N>>
18 : std::integral_constant<GLenum, gl_type_v<T>> {};
19template <typename T> requires std::is_arithmetic_v<T>
20struct value_type<T> : std::integral_constant<GLenum, gl_type_v<T>> {};
21template <typename T, size_t N>
22struct value_type<vec<T, N>> : std::integral_constant<GLenum, gl_type_v<T>> {};
23//==============================================================================
25template <typename F, typename... Ts>
26void for_each(F&& f, Ts&&... ts) {
27 using discard_t = int[];
28 // creates an array filled with zeros. while doing this f gets called with
29 // elements of ts
30 (void)discard_t{0, ((void)f(std::forward<Ts>(ts)), 0)...};
31}
32//==============================================================================
33template <typename T, typename... Ts>
34struct head {
35 using type = T;
36};
37template <typename... Ts>
38using head_t = typename head<Ts...>::type;
39//==============================================================================
40} // namespace tatooine::gl
41//==============================================================================
42#endif
Definition: ansiformat.h:6
static constexpr auto value_type_v
Definition: utility.h:15
void for_each(F &&f, Ts &&... ts)
Applies function F to all elements of parameter pack ts.
Definition: utility.h:26
typename head< Ts... >::type head_t
Definition: utility.h:38
Definition: utility.h:34
T type
Definition: utility.h:35
Definition: utility.h:13
Definition: vec.h:12