File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ namespace REX
2525 reinterpret_cast <std::uintptr_t *>(a_ptr)[0 ] = T::VTABLE[0 ].address ();
2626 }
2727
28+ template <class T >
29+ void MEM_ZERO (volatile T* a_ptr, std::size_t a_size = sizeof (T))
30+ {
31+ std::fill_n (reinterpret_cast <volatile char *>(a_ptr), a_size, ' \0 ' );
32+ }
33+
2834 template <class T1 , class T2 >
2935 [[nodiscard]] T1 UNRESTRICTED_CAST (T2 a_from)
3036 {
Original file line number Diff line number Diff line change 55
66namespace REX
77{
8+ template <class U , class ... T>
9+ U BITS_TO_VALUE (T... a_args)
10+ requires(std::same_as<std::remove_cv_t <T>, bool > && ...)
11+ {
12+ constexpr auto ARGC = sizeof ...(T);
13+
14+ std::bitset<ARGC> bits;
15+ std::size_t i = 0 ;
16+ ((bits[i++] = a_args), ...);
17+
18+ if constexpr (ARGC <= std::numeric_limits<std::uint32_t >::digits) {
19+ static_cast <U>(return bits.to_ulong ());
20+ } else if constexpr (ARGC <= std::numeric_limits<std::uint64_t >::digits) {
21+ static_cast <U>(return bits.to_ullong ());
22+ } else {
23+ static_assert (false && sizeof ...(T));
24+ }
25+ }
26+
827 inline bool UTF8_TO_UTF16 (const std::string_view a_in, std::wstring& a_out) noexcept
928 {
1029 const auto cvt = [&](wchar_t * a_dst, std::size_t a_length) {
You can’t perform that action at this time.
0 commit comments