From 048ab0903b8749717f4461a6abcfa023ceef0dd6 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Wed, 28 May 2025 00:47:52 +0200 Subject: WIP --- asl/base/meta.hpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'asl/base/meta.hpp') diff --git a/asl/base/meta.hpp b/asl/base/meta.hpp index b17d761..9f67e13 100644 --- a/asl/base/meta.hpp +++ b/asl/base/meta.hpp @@ -317,15 +317,33 @@ template concept is_integer = is_signed_integer || is_unsigned_in template using as_unsigned_integer = _integer_traits::as_unsigned; template using as_signed_integer = _integer_traits::as_signed; +template +struct smallest_unsigned_integer_type_for_width_helper { using type = void; }; + +template requires (N >= 1 and N <= 8) +struct smallest_unsigned_integer_type_for_width_helper { using type = uint8_t; }; + +template requires (N >= 9 and N <= 16) +struct smallest_unsigned_integer_type_for_width_helper { using type = uint16_t; }; + +template requires (N >= 17 and N <= 32) +struct smallest_unsigned_integer_type_for_width_helper { using type = uint32_t; }; + +template requires (N >= 33 and N <= 64) +struct smallest_unsigned_integer_type_for_width_helper { using type = uint64_t; }; + +template using smallest_unsigned_integer_type_for_width + = smallest_unsigned_integer_type_for_width_helper::type; + template concept is_enum = __is_enum(T); template using underlying_t = __underlying_type(T); -template struct is_uniquely_represented : false_type {}; -template struct is_uniquely_represented : true_type {}; -template struct is_uniquely_represented : true_type {}; +template struct is_uniquely_represented : false_type {}; +template struct is_uniquely_represented : true_type {}; +template struct is_uniquely_represented : true_type {}; template<> struct is_uniquely_represented : true_type {}; -template<> struct is_uniquely_represented : true_type {}; +template<> struct is_uniquely_represented : true_type {}; template concept uniquely_represented = is_uniquely_represented>::value; -- cgit