Skip to content

Commit 5a4f177

Browse files
pkastingmordante
authored andcommitted
[libc++] Avoid a Microsoft SAL macro.
Bug: #55195 Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D124695
1 parent 617edfa commit 5a4f177

File tree

7 files changed

+138
-136
lines changed

7 files changed

+138
-136
lines changed

libcxx/include/__functional/bind_back.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ struct __bind_back_op;
3131

3232
template <size_t _NBound, size_t ..._Ip>
3333
struct __bind_back_op<_NBound, index_sequence<_Ip...>> {
34-
template <class _Fn, class _Bound, class ..._Args>
35-
_LIBCPP_HIDE_FROM_ABI
36-
constexpr auto operator()(_Fn&& __f, _Bound&& __bound, _Args&& ...__args) const
37-
noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...)))
38-
-> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...))
39-
{ return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...); }
34+
template <class _Fn, class _BoundArgs, class... _Args>
35+
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f, _BoundArgs&& __bound_args, _Args&&... __args) const
36+
noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...,
37+
_VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...)))
38+
-> decltype(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...,
39+
_VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...)) {
40+
return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...,
41+
_VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...);
42+
}
4043
};
4144

4245
template <class _Fn, class _BoundArgs>

libcxx/include/__functional/perfect_forward.h

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -25,63 +25,64 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2525

2626
#if _LIBCPP_STD_VER > 14
2727

28-
template <class _Op, class _Indices, class ..._Bound>
28+
template <class _Op, class _Indices, class... _BoundArgs>
2929
struct __perfect_forward_impl;
3030

31-
template <class _Op, size_t ..._Idx, class ..._Bound>
32-
struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _Bound...> {
31+
template <class _Op, size_t... _Idx, class... _BoundArgs>
32+
struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _BoundArgs...> {
3333
private:
34-
tuple<_Bound...> __bound_;
34+
tuple<_BoundArgs...> __bound_args_;
3535

3636
public:
37-
template <class ..._BoundArgs, class = enable_if_t<
38-
is_constructible_v<tuple<_Bound...>, _BoundArgs&&...>
39-
>>
40-
explicit constexpr __perfect_forward_impl(_BoundArgs&& ...__bound)
41-
: __bound_(_VSTD::forward<_BoundArgs>(__bound)...)
42-
{ }
43-
44-
__perfect_forward_impl(__perfect_forward_impl const&) = default;
45-
__perfect_forward_impl(__perfect_forward_impl&&) = default;
46-
47-
__perfect_forward_impl& operator=(__perfect_forward_impl const&) = default;
48-
__perfect_forward_impl& operator=(__perfect_forward_impl&&) = default;
49-
50-
template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound&..., _Args...>>>
51-
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &
52-
noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)))
53-
-> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))
54-
{ return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); }
55-
56-
template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound&..., _Args...>>>
57-
auto operator()(_Args&&...) & = delete;
58-
59-
template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound const&..., _Args...>>>
60-
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&
61-
noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)))
62-
-> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))
63-
{ return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); }
64-
65-
template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound const&..., _Args...>>>
66-
auto operator()(_Args&&...) const& = delete;
67-
68-
template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound..., _Args...>>>
69-
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &&
70-
noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)))
71-
-> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))
72-
{ return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); }
73-
74-
template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound..., _Args...>>>
75-
auto operator()(_Args&&...) && = delete;
76-
77-
template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound const..., _Args...>>>
78-
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&&
79-
noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)))
80-
-> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))
81-
{ return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); }
82-
83-
template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound const..., _Args...>>>
84-
auto operator()(_Args&&...) const&& = delete;
37+
template <class... _Args, class = enable_if_t< is_constructible_v<tuple<_BoundArgs...>, _Args&&...>>>
38+
explicit constexpr __perfect_forward_impl(_Args&&... __bound_args)
39+
: __bound_args_(_VSTD::forward<_Args>(__bound_args)...) {}
40+
41+
__perfect_forward_impl(__perfect_forward_impl const&) = default;
42+
__perfect_forward_impl(__perfect_forward_impl&&) = default;
43+
44+
__perfect_forward_impl& operator=(__perfect_forward_impl const&) = default;
45+
__perfect_forward_impl& operator=(__perfect_forward_impl&&) = default;
46+
47+
template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
48+
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) & noexcept(
49+
noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
50+
-> decltype(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)) {
51+
return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...);
52+
}
53+
54+
template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
55+
auto operator()(_Args&&...) & = delete;
56+
57+
template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
58+
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const& noexcept(
59+
noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
60+
-> decltype(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)) {
61+
return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...);
62+
}
63+
64+
template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
65+
auto operator()(_Args&&...) const& = delete;
66+
67+
template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs..., _Args...>>>
68+
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) && noexcept(
69+
noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
70+
-> decltype(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)) {
71+
return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...);
72+
}
73+
74+
template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs..., _Args...>>>
75+
auto operator()(_Args&&...) && = delete;
76+
77+
template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
78+
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&& noexcept(
79+
noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
80+
-> decltype(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)) {
81+
return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...);
82+
}
83+
84+
template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
85+
auto operator()(_Args&&...) const&& = delete;
8586
};
8687

8788
// __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require].

libcxx/include/__iterator/advance.h

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -117,64 +117,63 @@ struct __fn {
117117
}
118118
}
119119

120-
// Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound) denotes a range.
120+
// Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound_sentinel) denotes a range.
121121
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
122-
_LIBCPP_HIDE_FROM_ABI
123-
constexpr void operator()(_Ip& __i, _Sp __bound) const {
124-
// If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound)`.
122+
_LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Ip& __i, _Sp __bound_sentinel) const {
123+
// If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound_sentinel)`.
125124
if constexpr (assignable_from<_Ip&, _Sp>) {
126-
__i = _VSTD::move(__bound);
125+
__i = _VSTD::move(__bound_sentinel);
127126
}
128-
// Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound - i)`.
127+
// Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound_sentinel - i)`.
129128
else if constexpr (sized_sentinel_for<_Sp, _Ip>) {
130-
(*this)(__i, __bound - __i);
129+
(*this)(__i, __bound_sentinel - __i);
131130
}
132-
// Otherwise, while `bool(i != bound)` is true, increments `i`.
131+
// Otherwise, while `bool(i != bound_sentinel)` is true, increments `i`.
133132
else {
134-
while (__i != __bound) {
133+
while (__i != __bound_sentinel) {
135134
++__i;
136135
}
137136
}
138137
}
139138

140139
// Preconditions:
141-
// * If `n > 0`, [i, bound) denotes a range.
142-
// * If `n == 0`, [i, bound) or [bound, i) denotes a range.
143-
// * If `n < 0`, [bound, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`.
140+
// * If `n > 0`, [i, bound_sentinel) denotes a range.
141+
// * If `n == 0`, [i, bound_sentinel) or [bound_sentinel, i) denotes a range.
142+
// * If `n < 0`, [bound_sentinel, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`.
144143
// Returns: `n - M`, where `M` is the difference between the ending and starting position.
145144
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
146-
_LIBCPP_HIDE_FROM_ABI
147-
constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp __bound) const {
145+
_LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n,
146+
_Sp __bound_sentinel) const {
148147
_LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>),
149148
"If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true.");
150149
// If `S` and `I` model `sized_sentinel_for<S, I>`:
151150
if constexpr (sized_sentinel_for<_Sp, _Ip>) {
152-
// If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`.
151+
// If |n| >= |bound_sentinel - i|, equivalent to `ranges::advance(i, bound_sentinel)`.
153152
// __magnitude_geq(a, b) returns |a| >= |b|, assuming they have the same sign.
154153
auto __magnitude_geq = [](auto __a, auto __b) {
155154
return __a == 0 ? __b == 0 :
156155
__a > 0 ? __a >= __b :
157156
__a <= __b;
158157
};
159-
if (const auto __M = __bound - __i; __magnitude_geq(__n, __M)) {
160-
(*this)(__i, __bound);
158+
if (const auto __M = __bound_sentinel - __i; __magnitude_geq(__n, __M)) {
159+
(*this)(__i, __bound_sentinel);
161160
return __n - __M;
162161
}
163162

164163
// Otherwise, equivalent to `ranges::advance(i, n)`.
165164
(*this)(__i, __n);
166165
return 0;
167166
} else {
168-
// Otherwise, if `n` is non-negative, while `bool(i != bound)` is true, increments `i` but at
167+
// Otherwise, if `n` is non-negative, while `bool(i != bound_sentinel)` is true, increments `i` but at
169168
// most `n` times.
170-
while (__i != __bound && __n > 0) {
169+
while (__i != __bound_sentinel && __n > 0) {
171170
++__i;
172171
--__n;
173172
}
174173

175-
// Otherwise, while `bool(i != bound)` is true, decrements `i` but at most `-n` times.
174+
// Otherwise, while `bool(i != bound_sentinel)` is true, decrements `i` but at most `-n` times.
176175
if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) {
177-
while (__i != __bound && __n < 0) {
176+
while (__i != __bound_sentinel && __n < 0) {
178177
--__i;
179178
++__n;
180179
}

libcxx/include/__iterator/next.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,14 @@ struct __fn {
5858
}
5959

6060
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
61-
_LIBCPP_HIDE_FROM_ABI
62-
constexpr _Ip operator()(_Ip __x, _Sp __bound) const {
63-
ranges::advance(__x, __bound);
61+
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp __bound_sentinel) const {
62+
ranges::advance(__x, __bound_sentinel);
6463
return __x;
6564
}
6665

6766
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
68-
_LIBCPP_HIDE_FROM_ABI
69-
constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound) const {
70-
ranges::advance(__x, __n, __bound);
67+
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const {
68+
ranges::advance(__x, __n, __bound_sentinel);
7169
return __x;
7270
}
7371
};

libcxx/include/__iterator/prev.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ struct __fn {
5757
}
5858

5959
template <bidirectional_iterator _Ip>
60-
_LIBCPP_HIDE_FROM_ABI
61-
constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound) const {
62-
ranges::advance(__x, -__n, __bound);
60+
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound_iter) const {
61+
ranges::advance(__x, -__n, __bound_iter);
6362
return __x;
6463
}
6564
};

0 commit comments

Comments
 (0)