[libcxx-commits] [libcxx] [libc++][numeric] P0543R3: Saturation arithmetic (PR #77967)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jan 13 05:24:45 PST 2024


================
@@ -0,0 +1,119 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H
+#define _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H
+
+#include <__concepts/arithmetic.h>
+#include <__config>
+#include <__type_traits/decay.h>
+#include <__utility/cmp.h>
+#include <limits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+template <typename _Tp>
+concept __libcpp_standard_integer = __libcpp_unsigned_integer<decay_t<_Tp>> || __libcpp_signed_integer<decay_t<_Tp>>;
----------------
mordante wrote:

I don't like the proposed location of the concept, let's add it to `__concepts/arithmetic.h` with tests so it can be reused in the future. (I would prefer to have that in a separate patch.)

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


More information about the libcxx-commits mailing list