Iros
 
Loading...
Searching...
No Matches
smallest_unsigned_type.h
Go to the documentation of this file.
1#pragma once
2
5#include "di/meta/constexpr.h"
6#include "di/types/prelude.h"
7
8namespace di::math {
9namespace detail {
10 template<umax size>
12 if constexpr (size <= NumericLimits<u8>::max) {
13 return (u8) 0;
14 } else if constexpr (size <= NumericLimits<u16>::max) {
15 return (u16) 0;
16 } else if constexpr (size <= NumericLimits<u32>::max) {
17 return (u32) 0;
18 } else if constexpr (size <= NumericLimits<u64>::max) {
19 return (u64) 0;
20 } else {
21 return (umax) 0;
22 }
23 }
24}
25
26template<umax size>
28}
Definition abs.h:11
constexpr auto smallest_unsigned_type_helper(Constexpr< size >)
Definition smallest_unsigned_type.h:11
Definition abs.h:10
decltype(detail::smallest_unsigned_type_helper(c_< size >)) SmallestUnsignedType
Definition smallest_unsigned_type.h:27
__UINT64_TYPE__ u64
Definition integers.h:12
uintmax_t umax
Definition integers.h:39
__UINT8_TYPE__ u8
Definition integers.h:9
__UINT32_TYPE__ u32
Definition integers.h:11
__UINT16_TYPE__ u16
Definition integers.h:10
constexpr auto c_
A value of type Constexpr<val>.
Definition constexpr.h:252
A wrapper for a constexpr value.
Definition core.h:77