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.

4593. The first template argument of std::saturating_cast must be specifiable

Section: 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.

  1. Modify 26.10.17.2 [numeric.sat.cast] as indicated:

    template<class R, class T>
      constexpr R saturating_cast(T x) noexcept;
    

    -1- Constraints: R and T are signed or unsigned integer types (6.9.2 [basic.fundamental]).

    -2- Returns: If x is representable as a value of type R, x; otherwise, either the largest or smallest representable value of type R, whichever is closer to the value of x.

    -?- Remarks: An invocation may explicitly specify an argument for the template parameter R.