Skip to content

Commit

Permalink
Add bitWidth function acting on values type control.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaxyM authored Sep 5, 2024
1 parent 7ff9172 commit f1fc9c8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion include/crap/bit.d/bitwidthvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
#if (crap_lib_int_pow2 >= 202002L)
#include <bit>
#else
#include <climits>

#include "../functional.d/plusvalue.h"
#include "../numbers.d/zero.h"
#include "../numeric.d/iotavalue.h"
#include <climits>
#include "../version.d/char8t.h"
#include "../version.d/unicodecharacters.h"
#endif

namespace crap
Expand All @@ -23,6 +26,18 @@ namespace crap
#else
template <class Type, Type Value> struct bitWidthValue
{
static_assert((std :: is_integral <Type> :: value) && (std :: is_unsigned <Type> :: value) &&
!(std :: is_same <typename std :: remove_cv <Type> :: type, bool> :: value) &&
!(std :: is_same <typename std :: remove_cv <Type> :: type, char> :: value) &&
#if (crap_char8_t >= 201811L)
!(std :: is_same <typename std :: remove_cv <Type> :: type, char8_t> :: value) &&
#endif
#if (crap_unicode_characters >= 200704L)
!(std :: is_same <typename std :: remove_cv <Type> :: type, char16_t> :: value) &&
!(std :: is_same <typename std :: remove_cv <Type> :: type, char32_t> :: value) &&
#endif
!(std :: is_same <typename std :: remove_cv <Type> :: type, wchar_t> :: value),
"Unsupported type.");
private:
constexpr const static Type any = zero <Type> :: value;
constexpr const static Type zeros = any ^ any;
Expand Down

0 comments on commit f1fc9c8

Please sign in to comment.