[libcxx-commits] [libcxx] 5a4f177 - [libc++] Avoid a Microsoft SAL macro.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 5 11:08:39 PDT 2022
Author: Peter Kasting
Date: 2022-05-05T20:08:33+02:00
New Revision: 5a4f177c949e5ff56bc6af9c0145e2d0c1b29c4d
URL: https://github.com/llvm/llvm-project/commit/5a4f177c949e5ff56bc6af9c0145e2d0c1b29c4d
DIFF: https://github.com/llvm/llvm-project/commit/5a4f177c949e5ff56bc6af9c0145e2d0c1b29c4d.diff
LOG: [libc++] Avoid a Microsoft SAL macro.
Bug: https://github.com/llvm/llvm-project/issues/55195
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D124695
Added:
Modified:
libcxx/include/__functional/bind_back.h
libcxx/include/__functional/perfect_forward.h
libcxx/include/__iterator/advance.h
libcxx/include/__iterator/next.h
libcxx/include/__iterator/prev.h
libcxx/include/__ranges/iota_view.h
libcxx/test/libcxx/nasty_macros.compile.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/include/__functional/bind_back.h b/libcxx/include/__functional/bind_back.h
index d64981aa9eb86a..266552265831a8 100644
--- a/libcxx/include/__functional/bind_back.h
+++ b/libcxx/include/__functional/bind_back.h
@@ -31,12 +31,15 @@ struct __bind_back_op;
template <size_t _NBound, size_t ..._Ip>
struct __bind_back_op<_NBound, index_sequence<_Ip...>> {
- template <class _Fn, class _Bound, class ..._Args>
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Fn&& __f, _Bound&& __bound, _Args&& ...__args) const
- noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...)))
- -> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...))
- { return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...); }
+ template <class _Fn, class _BoundArgs, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f, _BoundArgs&& __bound_args, _Args&&... __args) const
+ noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...,
+ _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...)))
+ -> decltype(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...,
+ _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...)) {
+ return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...,
+ _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...);
+ }
};
template <class _Fn, class _BoundArgs>
diff --git a/libcxx/include/__functional/perfect_forward.h b/libcxx/include/__functional/perfect_forward.h
index 9acaa7e98f0050..ad925f0977d051 100644
--- a/libcxx/include/__functional/perfect_forward.h
+++ b/libcxx/include/__functional/perfect_forward.h
@@ -25,63 +25,64 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 14
-template <class _Op, class _Indices, class ..._Bound>
+template <class _Op, class _Indices, class... _BoundArgs>
struct __perfect_forward_impl;
-template <class _Op, size_t ..._Idx, class ..._Bound>
-struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _Bound...> {
+template <class _Op, size_t... _Idx, class... _BoundArgs>
+struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _BoundArgs...> {
private:
- tuple<_Bound...> __bound_;
+ tuple<_BoundArgs...> __bound_args_;
public:
- template <class ..._BoundArgs, class = enable_if_t<
- is_constructible_v<tuple<_Bound...>, _BoundArgs&&...>
- >>
- explicit constexpr __perfect_forward_impl(_BoundArgs&& ...__bound)
- : __bound_(_VSTD::forward<_BoundArgs>(__bound)...)
- { }
-
- __perfect_forward_impl(__perfect_forward_impl const&) = default;
- __perfect_forward_impl(__perfect_forward_impl&&) = default;
-
- __perfect_forward_impl& operator=(__perfect_forward_impl const&) = default;
- __perfect_forward_impl& operator=(__perfect_forward_impl&&) = default;
-
- template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound&..., _Args...>>>
- _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &
- noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)))
- -> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))
- { return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); }
-
- template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound&..., _Args...>>>
- auto operator()(_Args&&...) & = delete;
-
- template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound const&..., _Args...>>>
- _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&
- noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)))
- -> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))
- { return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); }
-
- template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound const&..., _Args...>>>
- auto operator()(_Args&&...) const& = delete;
-
- template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound..., _Args...>>>
- _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &&
- noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)))
- -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))
- { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); }
-
- template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound..., _Args...>>>
- auto operator()(_Args&&...) && = delete;
-
- template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound const..., _Args...>>>
- _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&&
- noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)))
- -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))
- { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); }
-
- template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound const..., _Args...>>>
- auto operator()(_Args&&...) const&& = delete;
+ template <class... _Args, class = enable_if_t< is_constructible_v<tuple<_BoundArgs...>, _Args&&...>>>
+ explicit constexpr __perfect_forward_impl(_Args&&... __bound_args)
+ : __bound_args_(_VSTD::forward<_Args>(__bound_args)...) {}
+
+ __perfect_forward_impl(__perfect_forward_impl const&) = default;
+ __perfect_forward_impl(__perfect_forward_impl&&) = default;
+
+ __perfect_forward_impl& operator=(__perfect_forward_impl const&) = default;
+ __perfect_forward_impl& operator=(__perfect_forward_impl&&) = default;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) & noexcept(
+ noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)) {
+ return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
+ auto operator()(_Args&&...) & = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const& noexcept(
+ noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)) {
+ return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
+ auto operator()(_Args&&...) const& = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) && noexcept(
+ noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)) {
+ return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs..., _Args...>>>
+ auto operator()(_Args&&...) && = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&& noexcept(
+ noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)) {
+ return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
+ auto operator()(_Args&&...) const&& = delete;
};
// __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require].
diff --git a/libcxx/include/__iterator/advance.h b/libcxx/include/__iterator/advance.h
index 5a02e7d8f10ba6..4b8b0dc970a176 100644
--- a/libcxx/include/__iterator/advance.h
+++ b/libcxx/include/__iterator/advance.h
@@ -117,47 +117,46 @@ struct __fn {
}
}
- // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound) denotes a range.
+ // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound_sentinel) denotes a range.
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
- _LIBCPP_HIDE_FROM_ABI
- constexpr void operator()(_Ip& __i, _Sp __bound) const {
- // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound)`.
+ _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Ip& __i, _Sp __bound_sentinel) const {
+ // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound_sentinel)`.
if constexpr (assignable_from<_Ip&, _Sp>) {
- __i = _VSTD::move(__bound);
+ __i = _VSTD::move(__bound_sentinel);
}
- // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound - i)`.
+ // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound_sentinel - i)`.
else if constexpr (sized_sentinel_for<_Sp, _Ip>) {
- (*this)(__i, __bound - __i);
+ (*this)(__i, __bound_sentinel - __i);
}
- // Otherwise, while `bool(i != bound)` is true, increments `i`.
+ // Otherwise, while `bool(i != bound_sentinel)` is true, increments `i`.
else {
- while (__i != __bound) {
+ while (__i != __bound_sentinel) {
++__i;
}
}
}
// Preconditions:
- // * If `n > 0`, [i, bound) denotes a range.
- // * If `n == 0`, [i, bound) or [bound, i) denotes a range.
- // * If `n < 0`, [bound, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`.
+ // * If `n > 0`, [i, bound_sentinel) denotes a range.
+ // * If `n == 0`, [i, bound_sentinel) or [bound_sentinel, i) denotes a range.
+ // * If `n < 0`, [bound_sentinel, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`.
// Returns: `n - M`, where `M` is the
diff erence between the ending and starting position.
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
- _LIBCPP_HIDE_FROM_ABI
- constexpr iter_
diff erence_t<_Ip> operator()(_Ip& __i, iter_
diff erence_t<_Ip> __n, _Sp __bound) const {
+ _LIBCPP_HIDE_FROM_ABI constexpr iter_
diff erence_t<_Ip> operator()(_Ip& __i, iter_
diff erence_t<_Ip> __n,
+ _Sp __bound_sentinel) const {
_LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>),
"If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true.");
// If `S` and `I` model `sized_sentinel_for<S, I>`:
if constexpr (sized_sentinel_for<_Sp, _Ip>) {
- // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`.
+ // If |n| >= |bound_sentinel - i|, equivalent to `ranges::advance(i, bound_sentinel)`.
// __magnitude_geq(a, b) returns |a| >= |b|, assuming they have the same sign.
auto __magnitude_geq = [](auto __a, auto __b) {
return __a == 0 ? __b == 0 :
__a > 0 ? __a >= __b :
__a <= __b;
};
- if (const auto __M = __bound - __i; __magnitude_geq(__n, __M)) {
- (*this)(__i, __bound);
+ if (const auto __M = __bound_sentinel - __i; __magnitude_geq(__n, __M)) {
+ (*this)(__i, __bound_sentinel);
return __n - __M;
}
@@ -165,16 +164,16 @@ struct __fn {
(*this)(__i, __n);
return 0;
} else {
- // Otherwise, if `n` is non-negative, while `bool(i != bound)` is true, increments `i` but at
+ // Otherwise, if `n` is non-negative, while `bool(i != bound_sentinel)` is true, increments `i` but at
// most `n` times.
- while (__i != __bound && __n > 0) {
+ while (__i != __bound_sentinel && __n > 0) {
++__i;
--__n;
}
- // Otherwise, while `bool(i != bound)` is true, decrements `i` but at most `-n` times.
+ // Otherwise, while `bool(i != bound_sentinel)` is true, decrements `i` but at most `-n` times.
if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) {
- while (__i != __bound && __n < 0) {
+ while (__i != __bound_sentinel && __n < 0) {
--__i;
++__n;
}
diff --git a/libcxx/include/__iterator/next.h b/libcxx/include/__iterator/next.h
index 3dab1bb39540d1..5363d6d58ecf6a 100644
--- a/libcxx/include/__iterator/next.h
+++ b/libcxx/include/__iterator/next.h
@@ -58,16 +58,14 @@ struct __fn {
}
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
- _LIBCPP_HIDE_FROM_ABI
- constexpr _Ip operator()(_Ip __x, _Sp __bound) const {
- ranges::advance(__x, __bound);
+ _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp __bound_sentinel) const {
+ ranges::advance(__x, __bound_sentinel);
return __x;
}
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
- _LIBCPP_HIDE_FROM_ABI
- constexpr _Ip operator()(_Ip __x, iter_
diff erence_t<_Ip> __n, _Sp __bound) const {
- ranges::advance(__x, __n, __bound);
+ _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_
diff erence_t<_Ip> __n, _Sp __bound_sentinel) const {
+ ranges::advance(__x, __n, __bound_sentinel);
return __x;
}
};
diff --git a/libcxx/include/__iterator/prev.h b/libcxx/include/__iterator/prev.h
index b410b2304d749f..eb997b91ba2024 100644
--- a/libcxx/include/__iterator/prev.h
+++ b/libcxx/include/__iterator/prev.h
@@ -57,9 +57,8 @@ struct __fn {
}
template <bidirectional_iterator _Ip>
- _LIBCPP_HIDE_FROM_ABI
- constexpr _Ip operator()(_Ip __x, iter_
diff erence_t<_Ip> __n, _Ip __bound) const {
- ranges::advance(__x, -__n, __bound);
+ _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_
diff erence_t<_Ip> __n, _Ip __bound_iter) const {
+ ranges::advance(__x, -__n, __bound_iter);
return __x;
}
};
diff --git a/libcxx/include/__ranges/iota_view.h b/libcxx/include/__ranges/iota_view.h
index 62e98d475b32e9..24cee3f112de8c 100644
--- a/libcxx/include/__ranges/iota_view.h
+++ b/libcxx/include/__ranges/iota_view.h
@@ -90,9 +90,9 @@ namespace ranges {
using iterator_category = input_iterator_tag;
};
- template<weakly_incrementable _Start, semiregular _Bound = unreachable_sentinel_t>
- requires __weakly_equality_comparable_with<_Start, _Bound> && copyable<_Start>
- class iota_view : public view_interface<iota_view<_Start, _Bound>> {
+ template <weakly_incrementable _Start, semiregular _BoundSentinel = unreachable_sentinel_t>
+ requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>
+ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> {
struct __iterator : public __iota_iterator_category<_Start> {
friend class iota_view;
@@ -271,35 +271,35 @@ namespace ranges {
friend class iota_view;
private:
- _Bound __bound_ = _Bound();
+ _BoundSentinel __bound_sentinel_ = _BoundSentinel();
public:
_LIBCPP_HIDE_FROM_ABI
__sentinel() = default;
- constexpr explicit __sentinel(_Bound __bound) : __bound_(std::move(__bound)) {}
+ constexpr explicit __sentinel(_BoundSentinel __bound_sentinel) : __bound_sentinel_(std::move(__bound_sentinel)) {}
_LIBCPP_HIDE_FROM_ABI
friend constexpr bool operator==(const __iterator& __x, const __sentinel& __y) {
- return __x.__value_ == __y.__bound_;
+ return __x.__value_ == __y.__bound_sentinel_;
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr iter_
diff erence_t<_Start> operator-(const __iterator& __x, const __sentinel& __y)
- requires sized_sentinel_for<_Bound, _Start>
+ requires sized_sentinel_for<_BoundSentinel, _Start>
{
- return __x.__value_ - __y.__bound_;
+ return __x.__value_ - __y.__bound_sentinel_;
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr iter_
diff erence_t<_Start> operator-(const __sentinel& __x, const __iterator& __y)
- requires sized_sentinel_for<_Bound, _Start>
+ requires sized_sentinel_for<_BoundSentinel, _Start>
{
return -(__y - __x);
}
};
_Start __value_ = _Start();
- _Bound __bound_ = _Bound();
+ _BoundSentinel __bound_sentinel_ = _BoundSentinel();
public:
_LIBCPP_HIDE_FROM_ABI
@@ -309,75 +309,76 @@ namespace ranges {
constexpr explicit iota_view(_Start __value) : __value_(std::move(__value)) { }
_LIBCPP_HIDE_FROM_ABI
- constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_Bound> __bound)
- : __value_(std::move(__value)), __bound_(std::move(__bound)) {
+ constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_BoundSentinel> __bound_sentinel)
+ : __value_(std::move(__value)), __bound_sentinel_(std::move(__bound_sentinel)) {
// Validate the precondition if possible.
- if constexpr (totally_ordered_with<_Start, _Bound>) {
- _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_),
+ if constexpr (totally_ordered_with<_Start, _BoundSentinel>) {
+ _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_sentinel_),
"Precondition violated: value is greater than bound.");
}
}
_LIBCPP_HIDE_FROM_ABI
constexpr iota_view(__iterator __first, __iterator __last)
- requires same_as<_Start, _Bound>
- : iota_view(std::move(__first.__value_), std::move(__last.__value_)) {}
+ requires same_as<_Start, _BoundSentinel>
+ : iota_view(std::move(__first.__value_), std::move(__last.__value_)) {}
_LIBCPP_HIDE_FROM_ABI
- constexpr iota_view(__iterator __first, _Bound __last)
- requires same_as<_Bound, unreachable_sentinel_t>
- : iota_view(std::move(__first.__value_), std::move(__last)) {}
+ constexpr iota_view(__iterator __first, _BoundSentinel __last)
+ requires same_as<_BoundSentinel, unreachable_sentinel_t>
+ : iota_view(std::move(__first.__value_), std::move(__last)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr iota_view(__iterator __first, __sentinel __last)
- requires (!same_as<_Start, _Bound> && !same_as<_Start, unreachable_sentinel_t>)
- : iota_view(std::move(__first.__value_), std::move(__last.__bound_)) {}
+ requires(!same_as<_Start, _BoundSentinel> && !same_as<_Start, unreachable_sentinel_t>)
+ : iota_view(std::move(__first.__value_), std::move(__last.__bound_sentinel_)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr __iterator begin() const { return __iterator{__value_}; }
_LIBCPP_HIDE_FROM_ABI
constexpr auto end() const {
- if constexpr (same_as<_Bound, unreachable_sentinel_t>)
+ if constexpr (same_as<_BoundSentinel, unreachable_sentinel_t>)
return unreachable_sentinel;
else
- return __sentinel{__bound_};
+ return __sentinel{__bound_sentinel_};
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator end() const requires same_as<_Start, _Bound> {
- return __iterator{__bound_};
+ constexpr __iterator end() const
+ requires same_as<_Start, _BoundSentinel>
+ {
+ return __iterator{__bound_sentinel_};
}
_LIBCPP_HIDE_FROM_ABI
constexpr auto size() const
- requires (same_as<_Start, _Bound> && __advanceable<_Start>) ||
- (integral<_Start> && integral<_Bound>) ||
- sized_sentinel_for<_Bound, _Start>
+ requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) ||
+ (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
{
- if constexpr (__integer_like<_Start> && __integer_like<_Bound>) {
+ if constexpr (__integer_like<_Start> && __integer_like<_BoundSentinel>) {
if (__value_ < 0) {
- if (__bound_ < 0) {
- return std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_);
+ if (__bound_sentinel_ < 0) {
+ return std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_sentinel_);
}
- return std::__to_unsigned_like(__bound_) + std::__to_unsigned_like(-__value_);
+ return std::__to_unsigned_like(__bound_sentinel_) + std::__to_unsigned_like(-__value_);
}
- return std::__to_unsigned_like(__bound_) - std::__to_unsigned_like(__value_);
+ return std::__to_unsigned_like(__bound_sentinel_) - std::__to_unsigned_like(__value_);
}
- return std::__to_unsigned_like(__bound_ - __value_);
+ return std::__to_unsigned_like(__bound_sentinel_ - __value_);
}
};
- template<class _Start, class _Bound>
- requires (!__integer_like<_Start> || !__integer_like<_Bound> ||
- (__signed_integer_like<_Start> == __signed_integer_like<_Bound>))
- iota_view(_Start, _Bound) -> iota_view<_Start, _Bound>;
+ template <class _Start, class _BoundSentinel>
+ requires(!__integer_like<_Start> || !__integer_like<_BoundSentinel> ||
+ (__signed_integer_like<_Start> == __signed_integer_like<_BoundSentinel>))
+ iota_view(_Start, _BoundSentinel) -> iota_view<_Start, _BoundSentinel>;
- template<class _Start, class _Bound>
- inline constexpr bool enable_borrowed_range<iota_view<_Start, _Bound>> = true;
+ template <class _Start, class _BoundSentinel>
+ inline constexpr bool enable_borrowed_range<iota_view<_Start, _BoundSentinel>> = true;
-namespace views {
-namespace __iota {
+ namespace views {
+ namespace __iota {
struct __fn {
template<class _Start>
_LIBCPP_HIDE_FROM_ABI
@@ -386,12 +387,12 @@ namespace __iota {
-> decltype( ranges::iota_view(std::forward<_Start>(__start)))
{ return ranges::iota_view(std::forward<_Start>(__start)); }
- template<class _Start, class _Bound>
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Start&& __start, _Bound&& __bound) const
- noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound))))
- -> decltype( ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound)))
- { return ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound)); }
+ template <class _Start, class _BoundSentinel>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Start&& __start, _BoundSentinel&& __bound_sentinel) const noexcept(
+ noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel))))
+ -> decltype(ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel))) {
+ return ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel));
+ }
};
} // namespace __iota
diff --git a/libcxx/test/libcxx/nasty_macros.compile.pass.cpp b/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
index 5916a11f7ec496..1e4d185d5e9531 100644
--- a/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
+++ b/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
@@ -78,6 +78,7 @@
// Obviously we can only define these on non-Windows platforms.
#ifndef _WIN32
# define __allocator NASTY_MACRO
+# define __bound NASTY_MACRO
# define __deallocate NASTY_MACRO
# define __deref NASTY_MACRO
# define __full NASTY_MACRO
More information about the libcxx-commits
mailing list