any_t const

v1
Brett 2024-03-22 19:32:59 -04:00
parent 2dd44ca6e7
commit 1256ec201c
2 changed files with 3 additions and 4 deletions

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
include(cmake/color.cmake) include(cmake/color.cmake)
set(BLT_VERSION 0.15.3) set(BLT_VERSION 0.15.4)
set(BLT_TEST_VERSION 0.0.1) set(BLT_TEST_VERSION 0.0.1)
set(BLT_TARGET BLT) set(BLT_TARGET BLT)

View File

@ -168,15 +168,14 @@ namespace blt::unsafe
{} {}
template<typename T> template<typename T>
buffer_any_t& set(const T& t) void set(const T& t) const
{ {
static_assert(std::is_trivially_copyable_v<T> && "Type must be trivially copyable"); static_assert(std::is_trivially_copyable_v<T> && "Type must be trivially copyable");
std::memcpy(_data, &t, sizeof(t)); std::memcpy(_data, &t, sizeof(t));
return *this;
} }
template<typename T> template<typename T>
T any_cast() T any_cast() const
{ {
static_assert(std::is_trivially_copyable_v<T> && "Type must be trivially copyable"); static_assert(std::is_trivially_copyable_v<T> && "Type must be trivially copyable");
T t; T t;