OGLplus  (0.59.0) a C++ wrapper for rendering APIs

fill.hpp
Go to the documentation of this file.
1 #ifndef EAGINE_VECT_FILL_HPP
9 #define EAGINE_VECT_FILL_HPP
10 
11 #include "data.hpp"
12 
13 namespace eagine::vect {
14 
15 template <typename T, int N, bool V>
16 struct fill {
17  static auto apply(T v) noexcept -> data_t<T, N, V> {
18  data_t<T, N, V> r;
19  for(int i = 0; i < N; ++i) {
20  r[i] = v;
21  }
22  return r;
23  }
24 };
25 
26 #if EAGINE_VECT_OPTS
27 
28 template <typename T, bool V>
29 struct fill<T, 0, V> {
30  static constexpr auto apply(T) noexcept {
31  return data_t<T, 0, V>{};
32  }
33 };
34 
35 template <typename T, bool V>
36 struct fill<T, 1, V> {
37  static constexpr auto apply(T v) noexcept {
38  return data_t<T, 1, V>{v};
39  }
40 };
41 
42 template <typename T, bool V>
43 struct fill<T, 2, V> {
44  static constexpr auto apply(T v) noexcept {
45  return data_t<T, 2, V>{v, v};
46  }
47 };
48 
49 template <typename T, bool V>
50 struct fill<T, 3, V> {
51  static constexpr auto apply(T v) noexcept {
52  return data_t<T, 3, V>{v, v, v};
53  }
54 };
55 
56 template <typename T, bool V>
57 struct fill<T, 4, V> {
58  static constexpr auto apply(T v) noexcept {
59  return data_t<T, 4, V>{v, v, v, v};
60  }
61 };
62 
63 template <typename T, bool V>
64 struct fill<T, 8, V> {
65  static constexpr auto apply(T v) noexcept {
66  return data_t<T, 8, V>{v, v, v, v, v, v, v, v};
67  }
68 };
69 
70 #endif
71 
72 } // namespace eagine::vect
73 
74 #endif // EAGINE_VECT_FILL_HPP
static auto fill(basic_span< T, P, S > spn, const V &v) -> basic_span< T, P, S >
Fills a span with copies of the specified value.
Definition: span_algo.hpp:536

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).