diff options
Diffstat (limited to 'libstdc++-v3/include/bits')
| -rw-r--r-- | libstdc++-v3/include/bits/intcmp.h | 120 | ||||
| -rw-r--r-- | libstdc++-v3/include/bits/iterator_concepts.h | 4 | ||||
| -rw-r--r-- | libstdc++-v3/include/bits/max_size_type.h | 6 | ||||
| -rw-r--r-- | libstdc++-v3/include/bits/sat_arith.h | 12 | ||||
| -rw-r--r-- | libstdc++-v3/include/bits/version.def | 12 | ||||
| -rw-r--r-- | libstdc++-v3/include/bits/version.h | 15 |
6 files changed, 144 insertions, 25 deletions
diff --git a/libstdc++-v3/include/bits/intcmp.h b/libstdc++-v3/include/bits/intcmp.h new file mode 100644 index 0000000..bb9c7f2 --- /dev/null +++ b/libstdc++-v3/include/bits/intcmp.h @@ -0,0 +1,120 @@ +// Integer comparison functions -*- C++ -*- + +// Copyright (C) 2020-2025 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file bits/intcmp.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{utility} + */ + +#ifndef _GLIBCXX_INTCMP_H +#define _GLIBCXX_INTCMP_H 1 + +#ifdef _GLIBCXX_SYSHDR +#pragma GCC system_header +#endif + +#include <bits/version.h> + +#ifdef __glibcxx_integer_comparison_functions // C++ >= 20 + +#include <type_traits> +#include <ext/numeric_traits.h> // __int_traits + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template<typename _Tp, typename _Up> + constexpr bool + cmp_equal(_Tp __t, _Up __u) noexcept + { + static_assert(__is_signed_or_unsigned_integer<_Tp>::value); + static_assert(__is_signed_or_unsigned_integer<_Up>::value); + + if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) + return __t == __u; + else if constexpr (is_signed_v<_Tp>) + return __t >= 0 && make_unsigned_t<_Tp>(__t) == __u; + else + return __u >= 0 && __t == make_unsigned_t<_Up>(__u); + } + + template<typename _Tp, typename _Up> + constexpr bool + cmp_not_equal(_Tp __t, _Up __u) noexcept + { return !std::cmp_equal(__t, __u); } + + template<typename _Tp, typename _Up> + constexpr bool + cmp_less(_Tp __t, _Up __u) noexcept + { + static_assert(__is_signed_or_unsigned_integer<_Tp>::value); + static_assert(__is_signed_or_unsigned_integer<_Up>::value); + + if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) + return __t < __u; + else if constexpr (is_signed_v<_Tp>) + return __t < 0 || make_unsigned_t<_Tp>(__t) < __u; + else + return __u >= 0 && __t < make_unsigned_t<_Up>(__u); + } + + template<typename _Tp, typename _Up> + constexpr bool + cmp_greater(_Tp __t, _Up __u) noexcept + { return std::cmp_less(__u, __t); } + + template<typename _Tp, typename _Up> + constexpr bool + cmp_less_equal(_Tp __t, _Up __u) noexcept + { return !std::cmp_less(__u, __t); } + + template<typename _Tp, typename _Up> + constexpr bool + cmp_greater_equal(_Tp __t, _Up __u) noexcept + { return !std::cmp_less(__t, __u); } + + template<typename _Res, typename _Tp> + constexpr bool + in_range(_Tp __t) noexcept + { + static_assert(__is_signed_or_unsigned_integer<_Res>::value); + static_assert(__is_signed_or_unsigned_integer<_Tp>::value); + using __gnu_cxx::__int_traits; + + if constexpr (is_signed_v<_Tp> == is_signed_v<_Res>) + return __int_traits<_Res>::__min <= __t + && __t <= __int_traits<_Res>::__max; + else if constexpr (is_signed_v<_Tp>) + return __t >= 0 + && make_unsigned_t<_Tp>(__t) <= __int_traits<_Res>::__max; + else + return __t <= make_unsigned_t<_Res>(__int_traits<_Res>::__max); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // __glibcxx_integer_comparison_functions +#endif // _GLIBCXX_INTCMP_H diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h index fd91b22..40ac808 100644 --- a/libstdc++-v3/include/bits/iterator_concepts.h +++ b/libstdc++-v3/include/bits/iterator_concepts.h @@ -39,9 +39,6 @@ #include <bits/ptr_traits.h> // to_address #include <bits/ranges_cmp.h> // identity, ranges::less -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpedantic" // __int128 - namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -1032,6 +1029,5 @@ namespace ranges #endif // C++20 library concepts _GLIBCXX_END_NAMESPACE_VERSION } // namespace std -#pragma GCC diagnostic pop #endif // C++20 #endif // _ITERATOR_CONCEPTS_H diff --git a/libstdc++-v3/include/bits/max_size_type.h b/libstdc++-v3/include/bits/max_size_type.h index a34b91a..537acee 100644 --- a/libstdc++-v3/include/bits/max_size_type.h +++ b/libstdc++-v3/include/bits/max_size_type.h @@ -44,10 +44,8 @@ // [iterator.concept.winc]) that are one bit wider than the widest supported // integer type. // -// The set of integer types we consider includes __int128 and unsigned __int128 -// (when they exist), even though they are really integer types only in GNU -// mode. This is to obtain a consistent ABI for these integer-class types -// across strict mode and GNU mode. +// The set of integer types we consider includes the extended integer types +// __int128 and unsigned __int128 (when they exist). namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/bits/sat_arith.h b/libstdc++-v3/include/bits/sat_arith.h index e036fc8..bce86d9 100644 --- a/libstdc++-v3/include/bits/sat_arith.h +++ b/libstdc++-v3/include/bits/sat_arith.h @@ -46,7 +46,7 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Add two integers, with saturation in case of overflow. - template<typename _Tp> requires __is_standard_integer<_Tp>::value + template<typename _Tp> requires __is_signed_or_unsigned_integer<_Tp>::value constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept { @@ -62,7 +62,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } /// Subtract one integer from another, with saturation in case of overflow. - template<typename _Tp> requires __is_standard_integer<_Tp>::value + template<typename _Tp> requires __is_signed_or_unsigned_integer<_Tp>::value constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept { @@ -78,7 +78,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } /// Multiply two integers, with saturation in case of overflow. - template<typename _Tp> requires __is_standard_integer<_Tp>::value + template<typename _Tp> requires __is_signed_or_unsigned_integer<_Tp>::value constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept { @@ -94,7 +94,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } /// Divide one integer by another, with saturation in case of overflow. - template<typename _Tp> requires __is_standard_integer<_Tp>::value + template<typename _Tp> requires __is_signed_or_unsigned_integer<_Tp>::value constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept { @@ -107,8 +107,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Divide one integer by another, with saturation in case of overflow. template<typename _Res, typename _Tp> - requires __is_standard_integer<_Res>::value - && __is_standard_integer<_Tp>::value + requires __is_signed_or_unsigned_integer<_Res>::value + && __is_signed_or_unsigned_integer<_Tp>::value constexpr _Res saturate_cast(_Tp __x) noexcept { diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index 412b9ce..5c010a4 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -879,8 +879,12 @@ ftms = { ftms = { name = concepts; + // 201806 P0898R3 Standard Library Concepts + // 201907 P1754R1 Rename concepts to standard_case for C++20 + // 202002 P1964R2 Wording for boolean-testable + // 202207 P2404R3 Move-only types for equality_comparable_with, etc. values = { - v = 202002; + v = 202207; cxxmin = 20; extra_cond = "__cpp_concepts >= 201907L"; }; @@ -1090,17 +1094,17 @@ ftms = { name = padded_layouts; no_stdname = true; // internal values = { - v = 1; + v = 202403; cxxmin = 26; }; }; ftms = { name = submdspan; - no_stdname = true; // TODO: change once complete values = { - v = 1; + v = 202411; cxxmin = 26; + extra_cond = "__glibcxx_constant_wrapper >= 202506L"; }; }; diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index 2b96934..26d0689 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -985,9 +985,9 @@ #if !defined(__cpp_lib_concepts) # if (__cplusplus >= 202002L) && (__cpp_concepts >= 201907L) -# define __glibcxx_concepts 202002L +# define __glibcxx_concepts 202207L # if defined(__glibcxx_want_all) || defined(__glibcxx_want_concepts) -# define __cpp_lib_concepts 202002L +# define __cpp_lib_concepts 202207L # endif # endif #endif /* !defined(__cpp_lib_concepts) */ @@ -1214,7 +1214,7 @@ #if !defined(__cpp_lib_padded_layouts) # if (__cplusplus > 202302L) -# define __glibcxx_padded_layouts 1L +# define __glibcxx_padded_layouts 202403L # if defined(__glibcxx_want_all) || defined(__glibcxx_want_padded_layouts) # endif # endif @@ -1222,9 +1222,10 @@ #undef __glibcxx_want_padded_layouts #if !defined(__cpp_lib_submdspan) -# if (__cplusplus > 202302L) -# define __glibcxx_submdspan 1L +# if (__cplusplus > 202302L) && (__glibcxx_constant_wrapper >= 202506L) +# define __glibcxx_submdspan 202411L # if defined(__glibcxx_want_all) || defined(__glibcxx_want_submdspan) +# define __cpp_lib_submdspan 202411L # endif # endif #endif /* !defined(__cpp_lib_submdspan) */ @@ -2037,7 +2038,7 @@ # define __cpp_lib_common_reference 202302L # endif # endif -#endif /* !defined(__cpp_lib_common_reference) && defined(__glibcxx_want_common_reference) */ +#endif /* !defined(__cpp_lib_common_reference) */ #undef __glibcxx_want_common_reference #if !defined(__cpp_lib_common_reference_wrapper) @@ -2047,7 +2048,7 @@ # define __cpp_lib_common_reference_wrapper 202302L # endif # endif -#endif /* !defined(__cpp_lib_common_reference_wrapper) && defined(__glibcxx_want_common_reference_wrapper) */ +#endif /* !defined(__cpp_lib_common_reference_wrapper) */ #undef __glibcxx_want_common_reference_wrapper #if !defined(__cpp_lib_formatters) |
