@@ -30,22 +30,46 @@ namespace sus::num {
30
30
// / A 32-bit unsigned integer.
31
31
struct u32 final {
32
32
_sus__unsigned_impl (u32 , /* PrimitiveT=*/ uint32_t , /* SignedT=*/ i32 );
33
+
34
+ /* * Construction from the underlying primitive type.
35
+ */
36
+ template <std::same_as<decltype (primitive_value)>
37
+ P> // Prevent implicit conversions.
38
+ constexpr inline u32 (P val) noexcept : primitive_value(val) {}
33
39
};
34
40
35
41
// / An 8-bit unsigned integer.
36
42
struct u8 final {
37
43
_sus__unsigned_impl (u8 , /* PrimitiveT=*/ uint8_t , /* SignedT=*/ i8 );
44
+
45
+ /* * Construction from the underlying primitive type.
46
+ */
47
+ template <std::same_as<decltype (primitive_value)>
48
+ P> // Prevent implicit conversions.
49
+ constexpr inline u8 (P val) noexcept : primitive_value(val) {}
38
50
};
39
51
40
52
// / A 16-bit unsigned integer.
41
53
struct u16 final {
42
54
_sus__unsigned_impl (u16 , /* PrimitiveT=*/ uint16_t , /* SignedT=*/ i16 );
55
+
56
+ /* * Construction from the underlying primitive type.
57
+ */
58
+ template <std::same_as<decltype (primitive_value)>
59
+ P> // Prevent implicit conversions.
60
+ constexpr inline u16 (P val) noexcept : primitive_value(val) {}
43
61
};
44
62
45
63
// / A 64-bit unsigned integer.
46
64
struct u64 final {
47
65
_sus__unsigned_impl (u64 , /* PrimitiveT=*/ uint64_t ,
48
66
/* SignedT=*/ i64 );
67
+
68
+ /* * Construction from the underlying primitive type.
69
+ */
70
+ template <std::same_as<decltype (primitive_value)>
71
+ P> // Prevent implicit conversions.
72
+ constexpr inline u64 (P val) noexcept : primitive_value(val) {}
49
73
};
50
74
51
75
// / A pointer-sized unsigned integer.
0 commit comments