From 8e6865188242bccb3d8aa857ddc990d72a058d3d Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 6 Dec 2019 16:36:01 +0100 Subject: Adapt o3tl::span to P1872R0 ..."span should have size_type, not index_type" (), as implemented by libc++ since "[libc++][P1872] span should have size_type, not index_type." All uses of index_type had been added to mitigate the previous std::span change from signed (ptrdiff_t) to unsigned (size_t) index_type, see 6ef8420fdbf8dff16de13147c5ab833bc5e01121 "Adapt o3tl::span to updated C++2a std::span". There is no easy solution to transparently support all three std::span variants currently out there (signed index_type, unsigned index_type, unsigned size_type), without causing compilation failures due to CPPUNIT_ASSERT_EQUAL with arguments of different types, or compiler warnings about mixed signed/unsigned comparisons. So rule out the oldest std::span variant (signed index_type) in configure.ac (so that o3tl::span will use its own hand-rolled code in that case) and simplify the uses of index_type to std::size_t (as had already been mentioned in 6ef8420fdbf8dff16de13147c5ab833bc5e01121). Change-Id: I6ddf424ffb7941da3f69ad66fd29ecd35f09afae Reviewed-on: https://gerrit.libreoffice.org/84652 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- o3tl/qa/test-span.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'o3tl') diff --git a/o3tl/qa/test-span.cxx b/o3tl/qa/test-span.cxx index 7ec67fa7fd91..3cb78ace1db2 100644 --- a/o3tl/qa/test-span.cxx +++ b/o3tl/qa/test-span.cxx @@ -9,6 +9,7 @@ #include +#include #include #include @@ -42,7 +43,7 @@ private: CPPUNIT_ASSERT_EQUAL(3, *v.crbegin()); CPPUNIT_ASSERT_EQUAL( o3tl::span::difference_type(3), v.crend() - v.crbegin()); - CPPUNIT_ASSERT_EQUAL(o3tl::span::index_type(3), v.size()); + CPPUNIT_ASSERT_EQUAL(std::size_t(3), v.size()); CPPUNIT_ASSERT(!v.empty()); CPPUNIT_ASSERT_EQUAL(2, v[1]); CPPUNIT_ASSERT_EQUAL(1, *v.data()); @@ -52,8 +53,8 @@ private: o3tl::span v1( d1 ); o3tl::span v2( d2 ); std::swap(v1, v2); - CPPUNIT_ASSERT_EQUAL(o3tl::span::index_type(4), v1.size()); - CPPUNIT_ASSERT_EQUAL(o3tl::span::index_type(2), v2.size()); + CPPUNIT_ASSERT_EQUAL(std::size_t(4), v1.size()); + CPPUNIT_ASSERT_EQUAL(std::size_t(2), v2.size()); } } }; -- cgit