Skip to content

[libc++] Remove _LIBCPP_HIDE_FROM_ABI from <ranges> and its subheaders #140475

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions libcxx/include/__ranges/access.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,28 @@ concept __unqualified_begin =

struct __fn {
template <class _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[]) const noexcept
[[nodiscard]] constexpr auto operator()(_Tp (&__t)[]) const noexcept
requires(sizeof(_Tp) >= 0) // Disallow incomplete element types.
{
return __t + 0;
}

template <class _Tp, size_t _Np>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept
[[nodiscard]] constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept
requires(sizeof(_Tp) >= 0) // Disallow incomplete element types.
{
return __t + 0;
}

template <class _Tp>
requires __member_begin<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.begin()))) {
[[nodiscard]] constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.begin()))) {
return _LIBCPP_AUTO_CAST(__t.begin());
}

template <class _Tp>
requires __unqualified_begin<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
noexcept(noexcept(_LIBCPP_AUTO_CAST(begin(__t)))) {
[[nodiscard]] constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(_LIBCPP_AUTO_CAST(begin(__t)))) {
return _LIBCPP_AUTO_CAST(begin(__t));
}

Expand Down Expand Up @@ -119,23 +117,21 @@ concept __unqualified_end =

struct __fn {
template <class _Tp, size_t _Np>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept
[[nodiscard]] constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept
requires(sizeof(_Tp) >= 0) // Disallow incomplete element types.
{
return __t + _Np;
}

template <class _Tp>
requires __member_end<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.end()))) {
[[nodiscard]] constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.end()))) {
return _LIBCPP_AUTO_CAST(__t.end());
}

template <class _Tp>
requires __unqualified_end<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
noexcept(noexcept(_LIBCPP_AUTO_CAST(end(__t)))) {
[[nodiscard]] constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(_LIBCPP_AUTO_CAST(end(__t)))) {
return _LIBCPP_AUTO_CAST(end(__t));
}

Expand All @@ -155,15 +151,15 @@ namespace __cbegin {
struct __fn {
template <class _Tp>
requires is_lvalue_reference_v<_Tp&&>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
[[nodiscard]] constexpr auto operator()(_Tp&& __t) const
noexcept(noexcept(ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t))))
-> decltype(ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t))) {
return ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t));
}

template <class _Tp>
requires is_rvalue_reference_v<_Tp&&>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
[[nodiscard]] constexpr auto operator()(_Tp&& __t) const
noexcept(noexcept(ranges::begin(static_cast<const _Tp&&>(__t))))
-> decltype(ranges::begin(static_cast<const _Tp&&>(__t))) {
return ranges::begin(static_cast<const _Tp&&>(__t));
Expand All @@ -183,16 +179,17 @@ namespace __cend {
struct __fn {
template <class _Tp>
requires is_lvalue_reference_v<_Tp&&>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
[[nodiscard]] constexpr auto operator()(_Tp&& __t) const
noexcept(noexcept(ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t))))
-> decltype(ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t))) {
return ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t));
}

template <class _Tp>
requires is_rvalue_reference_v<_Tp&&>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(
noexcept(ranges::end(static_cast<const _Tp&&>(__t)))) -> decltype(ranges::end(static_cast<const _Tp&&>(__t))) {
[[nodiscard]] constexpr auto operator()(_Tp&& __t) const
noexcept(noexcept(ranges::end(static_cast<const _Tp&&>(__t))))
-> decltype(ranges::end(static_cast<const _Tp&&>(__t))) {
return ranges::end(static_cast<const _Tp&&>(__t));
}
};
Expand Down
8 changes: 4 additions & 4 deletions libcxx/include/__ranges/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ namespace __all {
struct __fn : __range_adaptor_closure<__fn> {
template <class _Tp>
requires ranges::view<decay_t<_Tp>>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(
noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)))) -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))) {
[[nodiscard]] constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))))
-> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))) {
return _LIBCPP_AUTO_CAST(std::forward<_Tp>(__t));
}

template <class _Tp>
requires(!ranges::view<decay_t<_Tp>>) && requires(_Tp&& __t) { ranges::ref_view{std::forward<_Tp>(__t)}; }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
[[nodiscard]] constexpr auto operator()(_Tp&& __t) const
noexcept(noexcept(ranges::ref_view{std::forward<_Tp>(__t)})) {
return ranges::ref_view{std::forward<_Tp>(__t)};
}
Expand All @@ -55,7 +55,7 @@ struct __fn : __range_adaptor_closure<__fn> {
requires(
!ranges::view<decay_t<_Tp>> && !requires(_Tp&& __t) { ranges::ref_view{std::forward<_Tp>(__t)}; } &&
requires(_Tp&& __t) { ranges::owning_view{std::forward<_Tp>(__t)}; })
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
[[nodiscard]] constexpr auto operator()(_Tp&& __t) const
noexcept(noexcept(ranges::owning_view{std::forward<_Tp>(__t)})) {
return ranges::owning_view{std::forward<_Tp>(__t)};
}
Expand Down
24 changes: 12 additions & 12 deletions libcxx/include/__ranges/as_rvalue_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,33 @@ class as_rvalue_view : public view_interface<as_rvalue_view<_View>> {
_LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();

public:
_LIBCPP_HIDE_FROM_ABI as_rvalue_view()
as_rvalue_view()
requires default_initializable<_View>
= default;

_LIBCPP_HIDE_FROM_ABI constexpr explicit as_rvalue_view(_View __base) : __base_(std::move(__base)) {}
constexpr explicit as_rvalue_view(_View __base) : __base_(std::move(__base)) {}

_LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
constexpr _View base() const&
requires copy_constructible<_View>
{
return __base_;
}

_LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
constexpr _View base() && { return std::move(__base_); }

_LIBCPP_HIDE_FROM_ABI constexpr auto begin()
constexpr auto begin()
requires(!__simple_view<_View>)
{
return move_iterator(ranges::begin(__base_));
}

_LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
constexpr auto begin() const
requires range<const _View>
{
return move_iterator(ranges::begin(__base_));
}

_LIBCPP_HIDE_FROM_ABI constexpr auto end()
constexpr auto end()
requires(!__simple_view<_View>)
{
if constexpr (common_range<_View>) {
Expand All @@ -78,7 +78,7 @@ class as_rvalue_view : public view_interface<as_rvalue_view<_View>> {
}
}

_LIBCPP_HIDE_FROM_ABI constexpr auto end() const
constexpr auto end() const
requires range<const _View>
{
if constexpr (common_range<const _View>) {
Expand All @@ -88,13 +88,13 @@ class as_rvalue_view : public view_interface<as_rvalue_view<_View>> {
}
}

_LIBCPP_HIDE_FROM_ABI constexpr auto size()
constexpr auto size()
requires sized_range<_View>
{
return ranges::size(__base_);
}

_LIBCPP_HIDE_FROM_ABI constexpr auto size() const
constexpr auto size() const
requires sized_range<const _View>
{
return ranges::size(__base_);
Expand All @@ -111,15 +111,15 @@ namespace views {
namespace __as_rvalue {
struct __fn : __range_adaptor_closure<__fn> {
template <class _Range>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
[[nodiscard]] static constexpr auto
operator()(_Range&& __range) noexcept(noexcept(as_rvalue_view(std::forward<_Range>(__range))))
-> decltype(/*--------------------------*/ as_rvalue_view(std::forward<_Range>(__range))) {
return /*---------------------------------*/ as_rvalue_view(std::forward<_Range>(__range));
}

template <class _Range>
requires same_as<range_rvalue_reference_t<_Range>, range_reference_t<_Range>>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
[[nodiscard]] static constexpr auto
operator()(_Range&& __range) noexcept(noexcept(views::all(std::forward<_Range>(__range))))
-> decltype(/*--------------------------*/ views::all(std::forward<_Range>(__range))) {
return /*---------------------------------*/ views::all(std::forward<_Range>(__range));
Expand Down
43 changes: 20 additions & 23 deletions libcxx/include/__ranges/chunk_by_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS chunk_by_view : public view_interface

class __iterator;

_LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> __find_next(iterator_t<_View> __current) {
constexpr iterator_t<_View> __find_next(iterator_t<_View> __current) {
// Note: this duplicates a check in `optional` but provides a better error message.
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
__pred_.__has_value(), "Trying to call __find_next() on a chunk_by_view that does not have a valid predicate.");
Expand All @@ -75,7 +75,7 @@ class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS chunk_by_view : public view_interface
ranges::adjacent_find(__current, ranges::end(__base_), __reversed_pred), 1, ranges::end(__base_));
}

_LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> __find_prev(iterator_t<_View> __current)
constexpr iterator_t<_View> __find_prev(iterator_t<_View> __current)
requires bidirectional_range<_View>
{
// Attempting to decrement a begin iterator is a no-op (`__find_prev` would return the same argument given to it).
Expand All @@ -93,24 +93,24 @@ class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS chunk_by_view : public view_interface
}

public:
_LIBCPP_HIDE_FROM_ABI chunk_by_view()
chunk_by_view()
requires default_initializable<_View> && default_initializable<_Pred>
= default;

_LIBCPP_HIDE_FROM_ABI constexpr explicit chunk_by_view(_View __base, _Pred __pred)
constexpr explicit chunk_by_view(_View __base, _Pred __pred)
: __base_(std::move(__base)), __pred_(in_place, std::move(__pred)) {}

_LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
constexpr _View base() const&
requires copy_constructible<_View>
{
return __base_;
}

_LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
constexpr _View base() && { return std::move(__base_); }

_LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; }
constexpr const _Pred& pred() const { return *__pred_; }

_LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() {
constexpr __iterator begin() {
// Note: this duplicates a check in `optional` but provides a better error message.
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
__pred_.__has_value(), "Trying to call begin() on a chunk_by_view that does not have a valid predicate.");
Expand All @@ -122,7 +122,7 @@ class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS chunk_by_view : public view_interface
return {*this, std::move(__first), *__cached_begin_};
}

_LIBCPP_HIDE_FROM_ABI constexpr auto end() {
constexpr auto end() {
if constexpr (common_range<_View>) {
return __iterator{*this, ranges::end(__base_), ranges::end(__base_)};
} else {
Expand All @@ -143,8 +143,7 @@ class chunk_by_view<_View, _Pred>::__iterator {
_LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __current_ = iterator_t<_View>();
_LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __next_ = iterator_t<_View>();

_LIBCPP_HIDE_FROM_ABI constexpr __iterator(
chunk_by_view& __parent, iterator_t<_View> __current, iterator_t<_View> __next)
constexpr __iterator(chunk_by_view& __parent, iterator_t<_View> __current, iterator_t<_View> __next)
: __parent_(std::addressof(__parent)), __current_(__current), __next_(__next) {}

public:
Expand All @@ -153,67 +152,65 @@ class chunk_by_view<_View, _Pred>::__iterator {
using iterator_category = input_iterator_tag;
using iterator_concept = conditional_t<bidirectional_range<_View>, bidirectional_iterator_tag, forward_iterator_tag>;

_LIBCPP_HIDE_FROM_ABI __iterator() = default;
__iterator() = default;

_LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const {
constexpr value_type operator*() const {
// If the iterator is at end, this would return an empty range which can be checked by the calling code and doesn't
// necessarily lead to a bad access.
_LIBCPP_ASSERT_PEDANTIC(__current_ != __next_, "Trying to dereference past-the-end chunk_by_view iterator.");
return {__current_, __next_};
}

_LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() {
constexpr __iterator& operator++() {
// Attempting to increment an end iterator is a no-op (`__find_next` would return the same argument given to it).
_LIBCPP_ASSERT_PEDANTIC(__current_ != __next_, "Trying to increment past end chunk_by_view iterator.");
__current_ = __next_;
__next_ = __parent_->__find_next(__current_);
return *this;
}

_LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int) {
constexpr __iterator operator++(int) {
auto __tmp = *this;
++*this;
return __tmp;
}

_LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--()
constexpr __iterator& operator--()
requires bidirectional_range<_View>
{
__next_ = __current_;
__current_ = __parent_->__find_prev(__next_);
return *this;
}

_LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int)
constexpr __iterator operator--(int)
requires bidirectional_range<_View>
{
auto __tmp = *this;
--*this;
return __tmp;
}

_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) {
friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) {
return __x.__current_ == __y.__current_;
}

_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, default_sentinel_t) {
return __x.__current_ == __x.__next_;
}
friend constexpr bool operator==(const __iterator& __x, default_sentinel_t) { return __x.__current_ == __x.__next_; }
};

namespace views {
namespace __chunk_by {
struct __fn {
template <class _Range, class _Pred>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const
[[nodiscard]] constexpr auto operator()(_Range&& __range, _Pred&& __pred) const
noexcept(noexcept(/**/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))))
-> decltype(/*--*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) {
return /*-------------*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred));
}

template <class _Pred>
requires constructible_from<decay_t<_Pred>, _Pred>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
[[nodiscard]] constexpr auto operator()(_Pred&& __pred) const
noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred)));
}
Expand Down
Loading
Loading