30 template<
class T, size_t N>
32 static_assert(std::is_trivially_copyable_v<T>,
"T must be trivially copyable to be treated as raw bytes!!");
35 std::vector<std::byte> data;
36 data.reserve(N *
sizeof(
int));
38 for (
const auto& value : values) {
39 int iValue =
static_cast<
int>(value);
40 const auto* iValuePtr =
reinterpret_cast<
const std::byte*>(std::addressof(iValue));
41 data.insert(data.end(), iValuePtr, iValuePtr +
sizeof(
int));
47 const auto* valuesPtr =
reinterpret_cast<
const std::byte*>(values.data());
48 return { valuesPtr, valuesPtr + (
sizeof(T) * N) };
53 template<
class T, glm::length_t L, glm::qualifier Q>
55 std::array<T, L> array;
56 std::copy_n(glm::value_ptr(value), L, array.begin());
61 template<
class T, size_t N>
63 std::array<T, N> array;
64 std::copy_n(
static_cast<
const T*>(value), N, array.begin());
69 std::vector<std::byte> _data;
73 explicit vec_data(
const std::vector<std::byte>& data);
77 template<
class T, glm::length_t L, glm::qualifier Q>
79 template<
class T, glm::length_t L, glm::qualifier Q,
80 std::enable_if_t<(mstd::is_same_type_in_v<T,
bool,
int,
unsigned int,
float,
double> && mstd::is_in_range_v<L, 2, 4>),
84 mstd::is_same_type_in_v<T,
bool,
int,
unsigned int,
float,
double> && mstd::is_in_range_v<L, 2, 4>
86 : vec_data(_get_data(_to_array(value))) {
91 template<
class T, size_t N>
93 template<
class T, size_t N,
94 std::enable_if_t<(mstd::is_same_type_in_v<T,
bool,
int,
unsigned int,
float,
double> && mstd::is_in_range_v<N, 2, 4>),
98 mstd::is_same_type_in_v<T,
bool,
int,
unsigned int,
float,
double> && mstd::is_in_range_v<N, 2, 4>
100 : vec_data(_get_data(_to_array(value))) {
104 vec_data(
const vec_data& other);
106 vec_data(vec_data&& other)
noexcept;
112 vec_data& operator=(
const vec_data& other);
114 vec_data& operator=(vec_data&& other)
noexcept;
118 template<utils::glsl_vec T>
120 template<
class T, std::enable_if_t<utils::is_glsl_vec_v<T>,
bool> =
true>
123 return vec_traits<T>::get_value(*
this);
127 [[nodiscard]]
const std::vector<std::byte>& data()
const noexcept;
#define _GLSL_STRUCT_HAS_CXX20
check if compiler has c++ version greater or equal to c++20 and if user enabled c++20 features using ...
Definition config.hpp:142
#define _GLSL_STRUCT_HAS_CXX17
check if compiler has c++ version greater or equal to c++17
Definition config.hpp:130