diff --git a/include/byte.h b/include/gsl_byte.h similarity index 100% rename from include/byte.h rename to include/gsl_byte.h diff --git a/include/multi_span.h b/include/multi_span.h index 3d00c6e..c4a0eac 100644 --- a/include/multi_span.h +++ b/include/multi_span.h @@ -21,7 +21,7 @@ #include "gsl_assert.h" #include "gsl_util.h" -#include "byte.h" +#include "gsl_byte.h" #include #include #include diff --git a/include/span.h b/include/span.h index e52e14a..053b488 100644 --- a/include/span.h +++ b/include/span.h @@ -21,7 +21,7 @@ #include "gsl_assert.h" #include "gsl_util.h" -#include "byte.h" +#include "gsl_byte.h" #include #include #include @@ -154,18 +154,21 @@ struct is_allowed_element_type_conversion }; template -class span_iterator - : public std::iterator +class const_span_iterator { - using Base = std::iterator; - public: - using typename Base::reference; - using typename Base::pointer; - using typename Base::difference_type; + using iterator_category = std::random_access_iterator_tag; + using value_type = typename Span::element_type; + using difference_type = std::ptrdiff_t; - constexpr span_iterator() : span_iterator(nullptr, 0) {} - constexpr span_iterator(const Span* span, typename Span::index_type index) : span_(span), index_(index) + using const_pointer = std::add_const_t; + using pointer = const_pointer; + + using const_reference = std::add_const_t; + using reference = const_reference; + + constexpr const_span_iterator() : const_span_iterator(nullptr, 0) {} + constexpr const_span_iterator(const Span* span, typename Span::index_type index) : span_(span), index_(index) { Expects(span == nullptr || (index_ >= 0 && index <= span_->length())); } @@ -173,59 +176,59 @@ public: constexpr reference operator*() const { Expects(span_); return (*span_)[index_]; } constexpr pointer operator->() const { Expects(span_); return &((*span_)[index_]); } - constexpr span_iterator& operator++() noexcept + constexpr const_span_iterator& operator++() noexcept { Expects(span_ && index_ >= 0 && index_ < span_->length()); ++index_; return *this; } - constexpr span_iterator operator++(int) noexcept + constexpr const_span_iterator operator++(int) noexcept { auto ret = *this; ++(*this); return ret; } - constexpr span_iterator& operator--() noexcept + constexpr const_span_iterator& operator--() noexcept { Expects(span_ && index > 0 && index_ <= span_->length()); --index_; return *this; } - constexpr span_iterator operator--(int) noexcept + constexpr const_span_iterator operator--(int) noexcept { auto ret = *this; --(*this); return ret; } - constexpr span_iterator operator+(difference_type n) const noexcept + constexpr const_span_iterator operator+(difference_type n) const noexcept { auto ret{*this}; return ret += n; } - constexpr span_iterator& operator+=(difference_type n) noexcept + constexpr const_span_iterator& operator+=(difference_type n) noexcept { index_ += n; Expects(span_ && index_ >= 0 && index_ <= span_->length()); return *this; } - constexpr span_iterator operator-(difference_type n) const noexcept + constexpr const_span_iterator operator-(difference_type n) const noexcept { auto ret{*this}; return ret -= n; } - constexpr span_iterator& operator-=(difference_type n) noexcept + constexpr const_span_iterator& operator-=(difference_type n) noexcept { return *this += -n; } - constexpr difference_type operator-(const span_iterator& rhs) const noexcept + constexpr difference_type operator-(const const_span_iterator& rhs) const noexcept { Expects(span_ == rhs.span_); return index_ - rhs.index_; @@ -236,26 +239,26 @@ public: return *(*this + n); } - constexpr bool operator==(const span_iterator& rhs) const noexcept + constexpr bool operator==(const const_span_iterator& rhs) const noexcept { return span_ == rhs.span_ && index_ == rhs.index_; } - constexpr bool operator!=(const span_iterator& rhs) const noexcept { return !(*this == rhs); } + constexpr bool operator!=(const const_span_iterator& rhs) const noexcept { return !(*this == rhs); } - constexpr bool operator<(const span_iterator& rhs) const noexcept + constexpr bool operator<(const const_span_iterator& rhs) const noexcept { Expects(span_ == rhs.span_); return index_ < rhs.index_; } - constexpr bool operator<=(const span_iterator& rhs) const noexcept { return !(rhs < *this); } + constexpr bool operator<=(const const_span_iterator& rhs) const noexcept { return !(rhs < *this); } - constexpr bool operator>(const span_iterator& rhs) const noexcept { return rhs < *this; } + constexpr bool operator>(const const_span_iterator& rhs) const noexcept { return rhs < *this; } - constexpr bool operator>=(const span_iterator& rhs) const noexcept { return !(rhs > *this); } + constexpr bool operator>=(const const_span_iterator& rhs) const noexcept { return !(rhs > *this); } - void swap(span_iterator& rhs) noexcept + void swap(const_span_iterator& rhs) noexcept { std::swap(index_, rhs.index_); std::swap(m_span, rhs.m_span); @@ -266,6 +269,75 @@ private: ptrdiff_t index_; }; + +template +class span_iterator : public const_span_iterator +{ + using base_type = const_span_iterator; + +public: + using iterator_category = std::random_access_iterator_tag; + using value_type = typename Span::element_type; + using difference_type = std::ptrdiff_t; + + using pointer = value_type*; + using reference = value_type&; + + constexpr span_iterator() : base_type() {} + constexpr span_iterator(const Span* span, typename Span::index_type index) : base_type(span, index) {} + + constexpr reference operator*() const { return reinterpret_cast(base_type::operator*()); } + constexpr pointer operator->() const { return reinterpret_cast(base_type::operator->()); } + + constexpr span_iterator& operator++() noexcept { base_type::operator++(); return *this; } + + constexpr span_iterator operator++(int) noexcept { return base_type::operator++(1); } + + constexpr span_iterator& operator--() noexcept { base_type::operator--(); return *this; } + + constexpr span_iterator operator--(int) noexcept { return base_type::operator--(1); } + + constexpr span_iterator operator+(difference_type n) const noexcept { return base_type::operator+(n); } + + constexpr span_iterator& operator+=(difference_type n) noexcept { return base_type::operator+=(n); } + + constexpr span_iterator operator-(difference_type n) const noexcept { return base_type::operator-(n); } + + constexpr span_iterator& operator-=(difference_type n) noexcept { return base_type::operator-=(n); } + + constexpr difference_type operator-(const span_iterator& rhs) const noexcept { return base_type::operator-(rhs); } + + constexpr reference operator[](difference_type n) const noexcept { return *(*this + n); } + + constexpr bool operator==(const span_iterator& rhs) const noexcept { return base_type::operator==(rhs); } + + constexpr bool operator!=(const span_iterator& rhs) const noexcept { return !(*this == rhs); } + + constexpr bool operator<(const span_iterator& rhs) const noexcept { return base_type::operator<(rhs); } + + constexpr bool operator<=(const span_iterator& rhs) const noexcept { return !(rhs < *this); } + + constexpr bool operator>(const span_iterator& rhs) const noexcept { return rhs < *this; } + + constexpr bool operator>=(const span_iterator& rhs) const noexcept { return !(rhs > *this); } + + void swap(span_iterator& rhs) noexcept { base_type::swap(rhs); } +}; + +template +constexpr const_span_iterator operator+(typename const_span_iterator::difference_type n, + const const_span_iterator& rhs) noexcept +{ + return rhs + n; +} + +template +constexpr const_span_iterator operator-(typename const_span_iterator::difference_type n, + const const_span_iterator& rhs) noexcept +{ + return rhs - n; +} + template constexpr span_iterator operator+(typename span_iterator::difference_type n, const span_iterator& rhs) noexcept @@ -294,7 +366,9 @@ public: using reference = element_type&; using iterator = details::span_iterator>; + using const_iterator = details::span_iterator; using reverse_iterator = std::reverse_iterator; + using const_reverse_iterator = std::reverse_iterator; constexpr static const index_type extent = Extent; diff --git a/include/string_span.h b/include/string_span.h index 69c3a81..8aba362 100644 --- a/include/string_span.h +++ b/include/string_span.h @@ -21,7 +21,7 @@ #include "gsl_assert.h" #include "gsl_util.h" -#include "multi_span.h" +#include "span.h" #include #include @@ -72,19 +72,19 @@ namespace gsl // (sometimes needlessly) break existing programs when introduced. // -template +template using basic_zstring = CharT*; -template +template using czstring = basic_zstring; -template +template using cwzstring = basic_zstring; -template +template using zstring = basic_zstring; -template +template using wzstring = basic_zstring; // @@ -96,7 +96,7 @@ using wzstring = basic_zstring; // Will fail-fast if sentinel cannot be found before max elements are examined. // template -multi_span ensure_sentinel(T* seq, std::ptrdiff_t max = PTRDIFF_MAX) +span ensure_sentinel(T* seq, std::ptrdiff_t max = PTRDIFF_MAX) { auto cur = seq; while ((cur - seq) < max && *cur != Sentinel) ++cur; @@ -111,34 +111,34 @@ multi_span ensure_sentinel(T* seq, std::ptrdiff_t max = PTRDIF // the limit of size_type. // template -inline multi_span ensure_z(T* const & sz, std::ptrdiff_t max = PTRDIFF_MAX) +inline span ensure_z(T* const & sz, std::ptrdiff_t max = PTRDIFF_MAX) { return ensure_sentinel(sz, max); } // TODO (neilmac) there is probably a better template-magic way to get the const and non-const overloads to share an implementation -inline multi_span ensure_z(char* const& sz, std::ptrdiff_t max) +inline span ensure_z(char* const& sz, std::ptrdiff_t max) { auto len = strnlen(sz, narrow_cast(max)); Ensures(sz[len] == 0); return{ sz, static_cast(len) }; } -inline multi_span ensure_z(const char* const& sz, std::ptrdiff_t max) +inline span ensure_z(const char* const& sz, std::ptrdiff_t max) { auto len = strnlen(sz, narrow_cast(max)); Ensures(sz[len] == 0); return{ sz, static_cast(len) }; } -inline multi_span ensure_z(wchar_t* const& sz, std::ptrdiff_t max) +inline span ensure_z(wchar_t* const& sz, std::ptrdiff_t max) { auto len = wcsnlen(sz, narrow_cast(max)); Ensures(sz[len] == 0); return{ sz, static_cast(len) }; } -inline multi_span ensure_z(const wchar_t* const& sz, std::ptrdiff_t max) +inline span ensure_z(const wchar_t* const& sz, std::ptrdiff_t max) { auto len = wcsnlen(sz, narrow_cast(max)); Ensures(sz[len] == 0); @@ -146,10 +146,10 @@ inline multi_span ensure_z(const wchar_t* const& s } template -multi_span ensure_z(T(&sz)[N]) { return ensure_z(&sz[0], static_cast(N)); } +span ensure_z(T(&sz)[N]) { return ensure_z(&sz[0], static_cast(N)); } template -multi_span::type, dynamic_range> ensure_z(Cont& cont) +span::type, dynamic_extent> ensure_z(Cont& cont) { return ensure_z(cont.data(), static_cast(cont.length())); } @@ -216,9 +216,7 @@ namespace details // // string_span and relatives // -// Note that Extent is always single-dimension only -// -template +template class basic_string_span { public: @@ -227,8 +225,7 @@ public: using pointer = std::add_pointer_t; using reference = std::add_lvalue_reference_t; using const_reference = std::add_lvalue_reference_t; - using bounds_type = static_bounds; - using impl_type = multi_span; + using impl_type = span; using size_type = ptrdiff_t; using iterator = typename impl_type::iterator; @@ -296,52 +293,52 @@ public: {} // from containers. Containers must have .size() and .data() function signatures - template ::value - && !details::is_basic_string_span::value - && !(!std::is_const::value && std::is_const::value) // no converting const containers to non-const span - && std::is_convertible::value - && std::is_same().size(), *std::declval().data())>, DataType>::value> + template ::value + && !details::is_span::value + && std::is_convertible::value + && std::is_convertible().data())>::value> > - constexpr basic_string_span(Cont& cont) - : span_(cont.data(), cont.size()) - {} + constexpr basic_string_span(Cont& cont) : span_(cont.data(), cont.size()) {} // disallow creation from temporary containers and strings - template ::value - && !details::is_basic_string_span::value - && std::is_convertible::value - && std::is_same().size(), *std::declval().data())>, DataType>::value> - > - basic_string_span(Cont&& cont) = delete; + template ::value + && !details::is_span::value + && std::is_convertible::value + && std::is_convertible().data())>::value> + > + constexpr basic_string_span(const Cont& cont) : span_(cont.data(), cont.size()) {} #ifndef GSL_MSVC_HAS_SFINAE_SUBSTITUTION_ICE // from span template ::value - && std::is_convertible, bounds_type>::value> + std::is_convertible, impl_type>::value + > > - constexpr basic_string_span(multi_span other) noexcept + constexpr basic_string_span(span other) noexcept : span_(other) {} #else // from span - constexpr basic_string_span(multi_span other) noexcept + constexpr basic_string_span(span other) noexcept : span_(other) {} - template , value_type>::value>> - constexpr basic_string_span(multi_span, Extent> other) noexcept + template , value_type>::value>> + constexpr basic_string_span(span, Extent> other) noexcept : span_(other) {} #endif // from string_span template , - typename Dummy = std::enable_if_t::value && std::is_convertible::value> + typename = std::enable_if_t< + std::is_convertible::impl_type, impl_type>::value + > > constexpr basic_string_span(basic_string_span other) noexcept : span_(other.data(), other.length()) @@ -359,7 +356,7 @@ public: return{ span_.template first() }; } - constexpr basic_string_span first(size_type count) const noexcept + constexpr basic_string_span first(size_type count) const noexcept { return{ span_.first(count) }; } @@ -371,7 +368,7 @@ public: return{ span_.template last() }; } - constexpr basic_string_span last(size_type count) const noexcept + constexpr basic_string_span last(size_type count) const noexcept { return{ span_.last(count) }; } @@ -383,7 +380,7 @@ public: return{ span_.template subspan() }; } - constexpr basic_string_span subspan(size_type offset, size_type count = dynamic_range) const noexcept + constexpr basic_string_span subspan(size_type offset, size_type count = dynamic_extent) const noexcept { return{ span_.subspan(offset, count) }; } @@ -478,16 +475,16 @@ private: impl_type span_; }; -template +template using string_span = basic_string_span; -template +template using cstring_span = basic_string_span; -template +template using wstring_span = basic_string_span; -template +template using cwstring_span = basic_string_span; // @@ -527,7 +524,7 @@ inline std::wstring to_string(wstring_span<> view) // zero-terminated string span, used to convert // zero-terminated spans to legacy strings -template +template class basic_zstring_span { public: @@ -540,14 +537,14 @@ public: using zstring_type = basic_zstring; using const_zstring_type = basic_zstring; - using impl_type = multi_span; + using impl_type = span; using string_span_type = basic_string_span; - constexpr basic_zstring_span(impl_type multi_span) noexcept - : span_(multi_span) + constexpr basic_zstring_span(impl_type s) noexcept + : span_(s) { // expects a zero-terminated span - Expects(multi_span[multi_span.size() - 1] == '\0'); + Expects(s[s.size() - 1] == '\0'); } // copy @@ -588,22 +585,22 @@ private: impl_type span_; }; -template +template using zstring_span = basic_zstring_span; -template +template using wzstring_span = basic_zstring_span; -template +template using czstring_span = basic_zstring_span; -template +template using cwzstring_span = basic_zstring_span; } // namespace GSL // operator == -template , Extent>>::value> > @@ -617,7 +614,7 @@ bool operator==(gsl::basic_string_span one, const T& other) noexc #endif } -template , Extent>>::value && !gsl::details::is_basic_string_span::value> @@ -637,10 +634,10 @@ bool operator==(const T& one, gsl::basic_string_span other) noexc // VS treats temp and const containers as convertible to basic_string_span, // so the cases below are already covered by the previous operators -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> @@ -651,10 +648,10 @@ bool operator==(gsl::basic_string_span one, const T& other) noexc return std::equal(one.begin(), one.end(), tmp.begin(), tmp.end()); } -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> @@ -667,7 +664,7 @@ bool operator==(const T& one, gsl::basic_string_span other) noexc #endif // operator != -template , Extent>>::value> > @@ -676,7 +673,7 @@ bool operator!=(gsl::basic_string_span one, const T& other) noexc return !(one == other); } -template , Extent>>::value && !gsl::details::is_basic_string_span::value> @@ -691,10 +688,10 @@ bool operator!=(const T& one, gsl::basic_string_span other) noexc // VS treats temp and const containers as convertible to basic_string_span, // so the cases below are already covered by the previous operators -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> @@ -704,10 +701,10 @@ bool operator!=(gsl::basic_string_span one, const T& other) noexc return !(one == other); } -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> @@ -719,7 +716,7 @@ bool operator!=(const T& one, gsl::basic_string_span other) noexc #endif // operator< -template , Extent>>::value> > @@ -729,7 +726,7 @@ bool operator<(gsl::basic_string_span one, const T& other) noexce return std::lexicographical_compare(one.begin(), one.end(), tmp.begin(), tmp.end()); } -template , Extent>>::value && !gsl::details::is_basic_string_span::value> @@ -745,10 +742,10 @@ bool operator<(const T& one, gsl::basic_string_span other) noexce // VS treats temp and const containers as convertible to basic_string_span, // so the cases below are already covered by the previous operators -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> @@ -759,10 +756,10 @@ bool operator<(gsl::basic_string_span one, const T& other) noexce return std::lexicographical_compare(one.begin(), one.end(), tmp.begin(), tmp.end()); } -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> @@ -775,7 +772,7 @@ bool operator<(const T& one, gsl::basic_string_span other) noexce #endif // operator <= -template , Extent>>::value> > @@ -784,7 +781,7 @@ bool operator<=(gsl::basic_string_span one, const T& other) noexc return !(other < one); } -template , Extent>>::value && !gsl::details::is_basic_string_span::value> @@ -799,10 +796,10 @@ bool operator<=(const T& one, gsl::basic_string_span other) noexc // VS treats temp and const containers as convertible to basic_string_span, // so the cases below are already covered by the previous operators -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> @@ -812,10 +809,10 @@ bool operator<=(gsl::basic_string_span one, const T& other) noexc return !(other < one); } -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> @@ -827,7 +824,7 @@ bool operator<=(const T& one, gsl::basic_string_span other) noexc #endif // operator> -template , Extent>>::value> > @@ -836,7 +833,7 @@ bool operator>(gsl::basic_string_span one, const T& other) noexce return other < one; } -template , Extent>>::value && !gsl::details::is_basic_string_span::value> @@ -851,10 +848,10 @@ bool operator>(const T& one, gsl::basic_string_span other) noexce // VS treats temp and const containers as convertible to basic_string_span, // so the cases below are already covered by the previous operators -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> @@ -864,10 +861,10 @@ bool operator>(gsl::basic_string_span one, const T& other) noexce return other < one; } -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> @@ -879,7 +876,7 @@ bool operator>(const T& one, gsl::basic_string_span other) noexce #endif // operator >= -template , Extent>>::value> > @@ -888,7 +885,7 @@ bool operator>=(gsl::basic_string_span one, const T& other) noexc return !(one < other); } -template , Extent>>::value && !gsl::details::is_basic_string_span::value> @@ -903,10 +900,10 @@ bool operator>=(const T& one, gsl::basic_string_span other) noexc // VS treats temp and const containers as convertible to basic_string_span, // so the cases below are already covered by the previous operators -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> @@ -916,10 +913,10 @@ bool operator>=(gsl::basic_string_span one, const T& other) noexc return !(one < other); } -template ::value + !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value> diff --git a/tests/byte_tests.cpp b/tests/byte_tests.cpp index ff91e50..19456fd 100644 --- a/tests/byte_tests.cpp +++ b/tests/byte_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/tests/string_span_tests.cpp b/tests/string_span_tests.cpp index 6876253..f380be3 100644 --- a/tests/string_span_tests.cpp +++ b/tests/string_span_tests.cpp @@ -142,7 +142,7 @@ SUITE(string_span_tests) const char* ptr = "Hello"; const std::string str = "Hello"; const std::vector vec = { 'H', 'e', 'l', 'l', 'o' }; - gsl::multi_span sp = ensure_z("Hello"); + gsl::span sp = ensure_z("Hello"); // comparison to literal CHECK(span == cstring_span<>("Hello")); @@ -182,7 +182,7 @@ SUITE(string_span_tests) char* ptr = ar; std::string str = "Hello"; std::vector vec = { 'H', 'e', 'l', 'l', 'o' }; - gsl::multi_span sp = ensure_z(ar1); + gsl::span sp = ensure_z(ar1); // comparison to static array with no null termination CHECK(span == string_span<>(ar)); @@ -216,7 +216,7 @@ SUITE(string_span_tests) const char ar2[10] = "Hello"; const std::string str = "Hello"; const std::vector vec = { 'H', 'e', 'l', 'l', 'o' }; - gsl::multi_span sp = ensure_z("Hello"); + gsl::span sp = ensure_z("Hello"); cstring_span<> span = "Hello"; @@ -253,7 +253,7 @@ SUITE(string_span_tests) char* _ptr = _ar; std::string _str = "Hello"; std::vector _vec = { 'H', 'e', 'l', 'l', 'o' }; - gsl::multi_span _sp{ _ar, 5 }; + gsl::span _sp{ _ar, 5 }; CHECK(span == _ar); CHECK(span == _ar1); @@ -447,7 +447,7 @@ SUITE(string_span_tests) // from span of a final extent { - multi_span sp = "Hello"; + span sp = "Hello"; cstring_span<> span = sp; CHECK(span.length() == 6); } @@ -455,7 +455,7 @@ SUITE(string_span_tests) // from const span of a final extent to non-const string_span #ifdef CONFIRM_COMPILATION_ERRORS { - multi_span sp = "Hello"; + span sp = "Hello"; string_span<> span = sp; CHECK(span.length() == 6); } @@ -568,7 +568,7 @@ SUITE(string_span_tests) // from const span { std::vector vec = { 'H', 'e', 'l', 'l', 'o' }; - const multi_span inner = vec; + const span inner = vec; cstring_span<> span = inner; CHECK(span.length() == 5); } @@ -576,7 +576,7 @@ SUITE(string_span_tests) // from non-const span { std::vector vec = { 'H', 'e', 'l', 'l', 'o' }; - multi_span inner = vec; + span inner = vec; cstring_span<> span = inner; CHECK(span.length() == 5); } @@ -675,7 +675,7 @@ SUITE(string_span_tests) { #ifdef CONFIRM_COMPILATION_ERRORS std::vector vec = { 'H', 'e', 'l', 'l', 'o' }; - const multi_span inner = vec; + const span inner = vec; string_span<> span = inner; CHECK(span.length() == 5); #endif @@ -684,7 +684,7 @@ SUITE(string_span_tests) // from non-const span { std::vector vec = { 'H', 'e', 'l', 'l', 'o' }; - multi_span inner = vec; + span inner = vec; string_span<> span = inner; CHECK(span.length() == 5); } @@ -693,7 +693,7 @@ SUITE(string_span_tests) { #ifdef CONFIRM_COMPILATION_ERRORS const std::vector vec = { 'H', 'e', 'l', 'l', 'o' }; - const multi_span inner = vec; + const span inner = vec; string_span<> span = inner; CHECK(span.length() == 5); #endif @@ -746,7 +746,7 @@ SUITE(string_span_tests) T create() { return T{}; } template - void use(basic_string_span s) {} + void use(basic_string_span s) {} TEST(MoveConstructors) { @@ -769,12 +769,12 @@ SUITE(string_span_tests) // move span { - multi_span span = ensure_z("Hello"); + span span = ensure_z("Hello"); cstring_span<> span1 = std::move(span); CHECK(span1.length() == 5); } { - multi_span span = ensure_z("Hello"); + span span = ensure_z("Hello"); cstring_span<> span2 = move_wrapper(std::move(span)); CHECK(span2.length() == 5); }