microsoft / STL

MSVC's implementation of the C++ Standard Library.
Other
10.07k stars 1.49k forks source link

P0543R3 Saturation Arithmetic #4168

Open StephanTLavavej opened 10 months ago

StephanTLavavej commented 10 months ago

WG21-P0543R3 Saturation Arithmetic

Feature-test macro:

#define __cpp_lib_saturation_arithmetic 202311L

Note: We're focused on implementing the remaining library-only features in C++23. Until that's done, we will NOT be accepting PRs for C++26 features.

frederick-vs-ja commented 9 months ago

https://github.com/cplusplus/draft/commit/2b1867a3404562c4261722e0a913cbcbf5a0a476 indicates that there's another new freestanding feature-test macro.

#define __cpp_lib_freestanding_numeric 202311L
StephanTLavavej commented 5 months ago

MSVC compiler intrinsics are expected to be available by the time we implement this:

_sat_add_i8
_sat_add_i16
_sat_add_i32
_sat_add_i64
_sat_add_u8
_sat_add_u16
_sat_add_u32
_sat_add_u64
_sat_sub_i8
_sat_sub_i16
_sat_sub_i32
_sat_sub_i64
_sat_sub_u8
_sat_sub_u16
_sat_sub_u32
_sat_sub_u64

We'll need to check whether they're available on all platforms (@kbrady-msft's MSVC-PR-548218 said that codegen is initially available for x64 only), and we may need to declare them in intrin.h or intrin0.inl.h before we begin using them.