summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorPhilipp Fent <fent@in.tum.de>2022-04-14 17:06:02 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-04-19 14:18:33 +0100
commitfdb3f82fb324c3ddd7464d11c8ea60a98f486a0e (patch)
treeca95582ee36253a4dbd38dc0fa0d3a255fdb9368 /libstdc++-v3/testsuite
parent214d2860f4e1573f04ef57bfea59da0cc66883ce (diff)
libstdc++: Add pretty printer for std::span
This improves the debug output for C++20 spans. Before: {static extent = 18446744073709551615, _M_ptr = 0x7fffffffb9a8, _M_extent = {_M_extent_value = 2}} Now with StdSpanPrinter: std::span of length 2 = {1, 2} Signed-off-by: Philipp Fent <fent@in.tum.de> libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdSpanPrinter): Define. * testsuite/libstdc++-prettyprinters/cxx20.cc: Test it.
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx20.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx20.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx20.cc
index b0de25c27ec..76023df93fa 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx20.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx20.cc
@@ -18,8 +18,10 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
+#include <array>
#include <compare>
#include <iostream>
+#include <span>
struct X
{
@@ -54,6 +56,15 @@ main()
auto c10 = 0.0 <=> __builtin_nan("");
// { dg-final { note-test c10 "std::partial_ordering::unordered" } }
+ auto il = {1, 2};
+ auto s1 = std::span(il);
+ static_assert(s1.extent == std::size_t(-1));
+// { dg-final { note-test s1 {std::span of length 2 = {1, 2}} } }
+ auto a = std::array{3, 4};
+ auto s2 = std::span(a);
+ static_assert(s2.extent == std::size_t(2));
+// { dg-final { note-test s2 {std::span of length 2 = {3, 4}} } }
+
std::cout << "\n";
return 0; // Mark SPOT
}