2
3
4
5
6
7
8
11#ifndef _GLSL_STRUCT_SCALAR_DATA_HPP_
12 #define _GLSL_STRUCT_SCALAR_DATA_HPP_
14 #include <glslstruct/config.hpp>
17_GLSL_STRUCT_ERROR(
"This is only available for c++17 and greater!");
20 #include <glslstruct/type/traits/concepts/scalar_traits_concept.hpp>
24
25
26
32 static_assert(std::is_trivially_copyable_v<T>,
"T must be trivially copyable to be treated as raw bytes!!");
34 const auto* valueDataPtr =
reinterpret_cast<
const std::byte*>(std::addressof(value));
35 return { valueDataPtr, valueDataPtr +
sizeof(T) };
39 std::vector<std::byte> _data;
43 explicit scalar_data(
const std::vector<std::byte>& data);
45 explicit scalar_data(
bool value);
47 explicit scalar_data(
int value);
49 explicit scalar_data(
unsigned int value);
51 explicit scalar_data(
float value);
53 explicit scalar_data(
double value);
56 scalar_data(
const scalar_data& other);
58 scalar_data(scalar_data&& other)
noexcept;
64 scalar_data& operator=(
const scalar_data& other);
66 scalar_data& operator=(scalar_data&& other)
noexcept;
70 template<utils::glsl_scalar T>
72 template<
class T, std::enable_if_t<utils::is_glsl_scalar_v<T>,
bool> =
true>
75 return scalar_traits<T>::get_value(*
this);
79 [[nodiscard]]
const std::vector<std::byte>& data()
const noexcept;
#define _GLSL_STRUCT_CONSTEXPR20
constexpr keyword for c++20 and higher
Definition config.hpp:213
#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