diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b0f287..fd8c05f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5) include(cmake/color.cmake) -set(BLT_VERSION 0.15.2) +set(BLT_VERSION 0.15.3) set(BLT_TEST_VERSION 0.0.1) set(BLT_TARGET BLT) diff --git a/include/blt/std/any.h b/include/blt/std/any.h index a626fc5..851ce03 100644 --- a/include/blt/std/any.h +++ b/include/blt/std/any.h @@ -17,6 +17,7 @@ */ #include + #ifndef BLT_ANY_H #define BLT_ANY_H @@ -158,6 +159,32 @@ namespace blt::unsafe } }; + class buffer_any_t + { + private: + blt::u8* _data; + public: + explicit buffer_any_t(blt::u8* data): _data(data) + {} + + template + buffer_any_t& set(const T& t) + { + static_assert(std::is_trivially_copyable_v && "Type must be trivially copyable"); + std::memcpy(_data, &t, sizeof(t)); + return *this; + } + + template + T any_cast() + { + static_assert(std::is_trivially_copyable_v && "Type must be trivially copyable"); + T t; + std::memcpy(&t, _data, sizeof(T)); + return t; + } + }; + template class any_t_base {