From: Patrick Palka <ppalka@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: libstdc++@gcc.gnu.org, Patrick Palka <ppalka@redhat.com>
Subject: [PATCH] libstdc++/ranges: Define _S_has_simple_call_op on newer adaptors
Date: Tue, 16 Jan 2024 21:36:41 -0500 [thread overview]
Message-ID: <20240117023641.3389770-1-ppalka@redhat.com> (raw)
Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
-- >8 --
This compile-time and diagnostic improvement[1] is less important in
C++23 mode where deducing this is available and used in _Pipe, but for
benefit of C++20 mode and for consistency let's set the flag on the most
recently added range adaptors which lack it.
[1]: Defining _S_has_simple_call_op=true for a range adaptor closure
object signals that the adaptor has an operator() that's not overloaded
according to the constness/value category of the object, which in turn
allows us to implement the operator() of the composition of such adaptors
in a simpler way.
libstdc++-v3/ChangeLog:
* include/std/ranges (views::_Adjacent::_S_has_simple_call_op):
Define to true.
(views::_AsRvalue::_S_has_simple_call_op): Likewise.
(views::_Enumerate::_S_has_simple_call_op): Likewise.
(views::_AsConst::_S_has_simple_call_op): Likewise.
---
libstdc++-v3/include/std/ranges | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 7ef835f486a..66502cc1da4 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -5669,6 +5669,8 @@ namespace views::__adaptor
else
return adjacent_view<all_t<_Range>, _Nm>(std::forward<_Range>(__r));
}
+
+ static constexpr bool _S_has_simple_call_op = true;
};
template<size_t _Nm>
@@ -8844,6 +8846,8 @@ namespace views::__adaptor
else
return as_rvalue_view(std::forward<_Range>(__r));
}
+
+ static constexpr bool _S_has_simple_call_op = true;
};
inline constexpr _AsRvalue as_rvalue;
@@ -9147,6 +9151,8 @@ namespace views::__adaptor
constexpr auto
operator() [[nodiscard]] (_Range&& __r) const
{ return enumerate_view<all_t<_Range>>(std::forward<_Range>(__r)); }
+
+ static constexpr bool _S_has_simple_call_op = true;
};
inline constexpr _Enumerate enumerate;
@@ -9253,6 +9259,8 @@ namespace views::__adaptor
else
return as_const_view(std::forward<_Range>(__r));
}
+
+ static constexpr bool _S_has_simple_call_op = true;
};
inline constexpr _AsConst as_const;
--
2.43.0.367.g186b115d30
next reply other threads:[~2024-01-17 2:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 2:36 Patrick Palka [this message]
2024-01-17 7:22 ` Jonathan Wakely
2024-03-27 12:46 ` Patrick Palka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240117023641.3389770-1-ppalka@redhat.com \
--to=ppalka@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).