public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Only define std::span::at for C++26 [PR115335]
@ 2024-06-04 14:28 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2024-06-04 14:28 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Tested x86_64-linux. Pushed to trunk. Will backport to gcc-14 too.

-- >8 --

In r14-5689-g1fa85dcf656e2f I added std::span::at and made the correct
changes to the __cpp_lib_span macro (with tests for the correct value in
C++20/23/26). But I didn't make the declaration of std::span::at
actually depend on the macro, so it was defined for C++20 and C++23, not
only for C++26. This fixes that oversight.

libstdc++-v3/ChangeLog:

	PR libstdc++/115335
	* include/std/span (span::at): Guard with feature test macro.
---
 libstdc++-v3/include/std/span | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span
index 43e9cf82a54..00fc5279152 100644
--- a/libstdc++-v3/include/std/span
+++ b/libstdc++-v3/include/std/span
@@ -287,6 +287,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *(this->_M_ptr + __idx);
       }
 
+#if __cpp_lib_span >= 202311L // >= C++26
       [[nodiscard]]
       constexpr reference
       at(size_type __idx) const
@@ -296,6 +297,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 				       "of size %zu"), __idx, this->size());
 	return *(this->_M_ptr + __idx);
       }
+#endif
 
       [[nodiscard]]
       constexpr pointer
-- 
2.45.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-06-04 14:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-04 14:28 [committed] libstdc++: Only define std::span::at for C++26 [PR115335] Jonathan Wakely

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).