[Openmp-commits] [lld] [lldb] [polly] [flang] [llvm] [libunwind] [mlir] [clang-tools-extra] [libc] [openmp] [libcxxabi] [clang] [compiler-rt] [libcxx] [libc++][numeric] P0543R3: Saturation arithmetic (PR #77967)

Mark de Wever via Openmp-commits openmp-commits at lists.llvm.org
Thu Jan 18 09:32:05 PST 2024


================
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <numeric>
+
+// template<class R, class T>
+//   constexpr R saturate_cast(T x) noexcept;                    // freestanding
+
+#include <concepts>
+#include <numeric>
+
+template <typename R, typename T>
+concept CanDo = requires(T x) {
+  { std::saturate_cast<R>(x) } -> std::same_as<R>;
+};
+
+template <typename R, typename T>
+constexpr void test_constraint_success() {
+  static_assert(CanDo<R, T>);
----------------
mordante wrote:

```suggestion
  static_assert(CanDo<R, T>);
  static_assert(CanDo<T, R>);
```

https://github.com/llvm/llvm-project/pull/77967


More information about the Openmp-commits mailing list