This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
std::saturating_cast must be specifiableSection: 26.10.17.2 [numeric.sat.cast] Status: New Submitter: Jiang An Opened: 2026-06-02 Last modified: 2026-06-13
Priority: Not Prioritized
View all issues with New status.
Discussion:
Currently, 26.2 [algorithms.requirements]/15 allows implementations to reject explicitly
specifying template arguments for algorithms. Unfortunately, std::saturating_cast is also an
algorithm as it is specifying in the "Algorithms library" chapter, and its first template argument
must be explicitly specified. Without being "explicitly stated otherwise", std::saturating_cast
is effectively unusable.
Proposed resolution:
This wording is relative to N5046.
Modify 26.10.17.2 [numeric.sat.cast] as indicated:
template<class R, class T> constexpr R saturating_cast(T x) noexcept;-1- Constraints:
-2- Returns: IfRandTare signed or unsigned integer types (6.9.2 [basic.fundamental]).xis representable as a value of typeR,x; otherwise, either the largest or smallest representable value of typeR, whichever is closer to the value ofx. -?- Remarks: An invocation may explicitly specify an argument for the template parameterR.