@@ -916,10 +916,10 @@ inline constexpr Int from_string(const std::string& s)
916
916
return from_string<Int>(s.c_str ());
917
917
}
918
918
919
- consteval uint128 operator " " _u128(const char * s)
920
- {
921
- return from_string<uint128>(s);
922
- }
919
+ // consteval uint128 operator""_u128(const char* s)
920
+ // {
921
+ // return from_string<uint128>(s);
922
+ // }
923
923
924
924
template <unsigned N>
925
925
inline std::string to_string (uint <N> x, int base = 10 )
@@ -1104,6 +1104,7 @@ using uint192 = uint<192>;
1104
1104
using uint256 = uint <256 >;
1105
1105
using uint320 = uint <320 >;
1106
1106
using uint384 = uint <384 >;
1107
+ using uint448 = uint <448 >;
1107
1108
using uint512 = uint <512 >;
1108
1109
1109
1110
template <unsigned N>
@@ -1843,17 +1844,27 @@ inline constexpr uint256 mulmod(const uint256& x, const uint256& y, const uint25
1843
1844
return udivrem (umul (x, y), mod).rem ;
1844
1845
}
1845
1846
1846
-
1847
- consteval uint256 operator " " _u256(const char * s)
1848
- {
1849
- return from_string<uint256>(s);
1850
- }
1851
-
1852
- consteval uint512 operator " " _u512(const char * s)
1853
- {
1854
- return from_string<uint512>(s);
1855
- }
1856
-
1847
+ // / Define type alias uintN = uint<N> and the matching literal ""_uN.
1848
+ // / The literal operators are defined in the intx::literals namespace.
1849
+ #define DEFINE_ALIAS_AND_LITERAL (N ) \
1850
+ using uint ##N = uint <N>; \
1851
+ namespace literals \
1852
+ { \
1853
+ consteval uint ##N operator " " _u##N(const char * s) \
1854
+ { \
1855
+ return from_string<uint ##N>(s); \
1856
+ } \
1857
+ }
1858
+ DEFINE_ALIAS_AND_LITERAL (128 );
1859
+ DEFINE_ALIAS_AND_LITERAL (192 );
1860
+ DEFINE_ALIAS_AND_LITERAL (256 );
1861
+ DEFINE_ALIAS_AND_LITERAL (320 );
1862
+ DEFINE_ALIAS_AND_LITERAL (384 );
1863
+ DEFINE_ALIAS_AND_LITERAL (448 );
1864
+ DEFINE_ALIAS_AND_LITERAL (512 );
1865
+ #undef DEFINE_ALIAS_AND_LITERAL
1866
+
1867
+ using namespace literals ;
1857
1868
1858
1869
// / Convert native representation to/from little-endian byte order.
1859
1870
// / intx and built-in integral types are supported.
0 commit comments