arithmetic.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef _LIBCPP___CONCEPTS_ARITHMETIC_H
  9. #define _LIBCPP___CONCEPTS_ARITHMETIC_H
  10. #include <__config>
  11. #include <__type_traits/is_floating_point.h>
  12. #include <__type_traits/is_integral.h>
  13. #include <__type_traits/is_signed.h>
  14. #include <__type_traits/is_signed_integer.h>
  15. #include <__type_traits/is_unsigned_integer.h>
  16. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  17. # pragma GCC system_header
  18. #endif
  19. _LIBCPP_BEGIN_NAMESPACE_STD
  20. #if _LIBCPP_STD_VER >= 20
  21. // [concepts.arithmetic], arithmetic concepts
  22. template <class _Tp>
  23. concept integral = is_integral_v<_Tp>;
  24. template <class _Tp>
  25. concept signed_integral = integral<_Tp> && is_signed_v<_Tp>;
  26. template <class _Tp>
  27. concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;
  28. template <class _Tp>
  29. concept floating_point = is_floating_point_v<_Tp>;
  30. // Concept helpers for the internal type traits for the fundamental types.
  31. template <class _Tp>
  32. concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value;
  33. template <class _Tp>
  34. concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value;
  35. #endif // _LIBCPP_STD_VER >= 20
  36. _LIBCPP_END_NAMESPACE_STD
  37. #endif // _LIBCPP___CONCEPTS_ARITHMETIC_H