From fdb3f82fb324c3ddd7464d11c8ea60a98f486a0e Mon Sep 17 00:00:00 2001 From: Philipp Fent Date: Thu, 14 Apr 2022 17:06:02 +0100 Subject: 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 libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdSpanPrinter): Define. * testsuite/libstdc++-prettyprinters/cxx20.cc: Test it. --- libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx20.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libstdc++-v3/testsuite') 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 // . +#include #include #include +#include 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 } -- cgit v1.2.3