Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor <limits> usage #4634

Merged
merged 32 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5b7d561
Avoid including <limits> to improve throughput
AlexGuteniev Apr 27, 2024
7ed2d06
expect test failures
AlexGuteniev Apr 27, 2024
362cb22
lift the limit for internal helper for `<regex>`
AlexGuteniev Apr 27, 2024
04fee98
one more skip
AlexGuteniev Apr 27, 2024
228b235
specialize `_Max_limit` for 128 bit
AlexGuteniev Apr 27, 2024
5adceae
avoid `_In_range` in `_Convert_size`
AlexGuteniev Apr 27, 2024
e123f28
one more skip
AlexGuteniev Apr 27, 2024
dd292a8
restrict to `<tr1common>`
AlexGuteniev Apr 27, 2024
61a2844
upstream knows
AlexGuteniev Apr 27, 2024
6e66be7
Update stl/inc/xlocnum
AlexGuteniev Apr 28, 2024
2f80b87
Revert "restrict to `<tr1common>`" +
AlexGuteniev Apr 28, 2024
5894028
<utility> is already there
AlexGuteniev Apr 28, 2024
07a711a
Merge branch 'no_limits' of https://github.com/AlexGuteniev/STL into …
AlexGuteniev Apr 28, 2024
e5d63d3
le-xi-co-graphically sort lines
AlexGuteniev Apr 30, 2024
85900ec
Avoid breaking old code
AlexGuteniev May 1, 2024
8d3e8ad
Merge branch 'no_limits' of https://github.com/AlexGuteniev/STL into …
AlexGuteniev May 1, 2024
516e1f3
unexpect test failures
AlexGuteniev May 1, 2024
8fdf232
Some tests still fail
AlexGuteniev May 2, 2024
4c623a5
Add `_Min_limit` for `_Unsigned128` and `_Signed128`.
StephanTLavavej May 17, 2024
f2a6ab1
Add `_STD` qualification in `<mdspan>`.
StephanTLavavej May 17, 2024
bd59736
Restore inclusion: `<xlocnum>` needs `<climits>`.
StephanTLavavej May 17, 2024
82344d2
`_In_range`: Use it more often; we control all types.
StephanTLavavej May 17, 2024
40fd472
`in_range`: Use it in `<semaphore>` with bonus cleanups.
StephanTLavavej May 17, 2024
90651a6
`in_range`: Use it in `<format>` and chronat.
StephanTLavavej May 17, 2024
4b70a7e
`_Meow_limit`: Use it in `_Could_compare_equal_to_value_type`.
StephanTLavavej May 17, 2024
6040623
`_Max_limit`: Use it in `_Mul_overflow`.
StephanTLavavej May 17, 2024
1461144
Be daring, part 1: `<algorithm>` and `<vector>` are now unlimited.
StephanTLavavej May 17, 2024
5a62472
Be daring, part 2: FAIL the other tests fixed by LLVM-90345.
StephanTLavavej May 17, 2024
8af943a
Be daring, part 3: Add an escape hatch.
StephanTLavavej May 17, 2024
5440892
GH 4646 <xutility>: unify min/max limit
StephanTLavavej May 17, 2024
942ccef
Be less daring, comment why, partially resurrect GH 3631 "Don't inclu…
StephanTLavavej May 18, 2024
0841c99
No more libcxx FAILs.
StephanTLavavej May 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 0 additions & 11 deletions stl/inc/utility
Original file line number Diff line number Diff line change
Expand Up @@ -849,17 +849,6 @@ _NODISCARD constexpr _Ty _Min_limit() noexcept { // same as (numeric_limits<_Ty>
}
}

template <class _Ty>
_NODISCARD constexpr _Ty _Max_limit() noexcept { // same as (numeric_limits<_Ty>::max)(), less throughput cost
_STL_INTERNAL_STATIC_ASSERT(is_integral_v<_Ty>); // doesn't attempt to handle all types
if constexpr (is_signed_v<_Ty>) {
constexpr auto _Unsigned_max = static_cast<make_unsigned_t<_Ty>>(-1);
return static_cast<_Ty>(_Unsigned_max >> 1);
} else {
return static_cast<_Ty>(-1);
}
}

template <class _Rx, class _Ty>
_NODISCARD constexpr bool _In_range(const _Ty _Value) noexcept {
static_assert(_Is_standard_integer<_Rx> && _Is_standard_integer<_Ty>,
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/xmemory
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <cstdint>
#include <cstdlib>
#include <new>
#include <utility>
#include <xatomic.h>
#include <xtr1common>
#include <xutility>
AlexGuteniev marked this conversation as resolved.
Show resolved Hide resolved

#if _HAS_CXX20
Expand Down
10 changes: 10 additions & 0 deletions stl/inc/xtr1common
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ struct remove_cvref {
};
#endif // _HAS_CXX20

template <class _Ty>
_NODISCARD constexpr _Ty _Max_limit() noexcept { // same as (numeric_limits<_Ty>::max)(), less throughput cost
_STL_INTERNAL_STATIC_ASSERT(is_integral_v<_Ty>); // doesn't attempt to handle all types
if constexpr (static_cast<_Ty>(-1) < _Ty{0}) {
return ~_Ty{-128 * (_Ty{1} << ((sizeof(_Ty) - 1) * 8))}; // Signed type, form 0x80..0 then bitwise negate
} else {
return static_cast<_Ty>(-1); // Unsigned tpye
}
}

_STD_END

// TRANSITION, non-_Ugly attribute tokens
Expand Down