Mercurial > minori
view include/core/bit_cast.h @ 382:0265e125f680
filesystem: implement filesystem watcher
I also ported the library code to use it as well. Once we implement
proper directory watching on Windows (and maybe others) this will
be fairly useful :)
| author | Paper <paper@tflc.us> |
|---|---|
| date | Thu, 06 Nov 2025 03:16:55 -0500 |
| parents | 47c9f8502269 |
| children |
line wrap: on
line source
#ifndef MINORI_CORE_BIT_CAST_H_ #define MINORI_CORE_BIT_CAST_H_ /* XXX need to move more "core" stuff into the minori namespace */ #include <cstring> #include <memory> #include <type_traits> namespace minori { /* C++17 doesn't have this unfortunately */ template<typename To, class From> To BitCast(From from) { static_assert(sizeof(From) == sizeof(To), "Types must match sizes"); static_assert(std::is_pod<From>::value, "Requires POD input"); static_assert(std::is_pod<To>::value, "Requires POD output"); To to; std::memcpy(std::addressof(to), std::addressof(from), sizeof(from)); return to; } } // namespace minori #endif /* MINORI_CORE_BIT_CAST_H_ */
