mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Addressed CR comments
This commit is contained in:
parent
b4ff206c24
commit
ed906e7aae
@ -527,7 +527,7 @@ inline std::wstring to_string(wstring_span<> view)
|
|||||||
|
|
||||||
// zero-terminated string span, used to convert
|
// zero-terminated string span, used to convert
|
||||||
// zero-terminated spans to legacy strings
|
// zero-terminated spans to legacy strings
|
||||||
template<typename CharT, size_t Extent = dynamic_range>
|
template<typename CharT, std::ptrdiff_t Extent = dynamic_range>
|
||||||
class basic_zstring_span
|
class basic_zstring_span
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -544,22 +544,48 @@ public:
|
|||||||
using string_span_type = basic_string_span<value_type, Extent>;
|
using string_span_type = basic_string_span<value_type, Extent>;
|
||||||
|
|
||||||
constexpr basic_zstring_span(impl_type span) noexcept
|
constexpr basic_zstring_span(impl_type span) noexcept
|
||||||
: sp_(span)
|
: span_(span)
|
||||||
{
|
{
|
||||||
// expects a zero-terminated span
|
// expects a zero-terminated span
|
||||||
Expects(span[span.size() - 1] == '\0');
|
Expects(span[span.size() - 1] == '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool empty() const noexcept { return sp_.size() == 0; }
|
// copy
|
||||||
|
constexpr basic_zstring_span(const basic_zstring_span& other) = default;
|
||||||
|
|
||||||
constexpr string_span_type as_string_span() const noexcept { return sp_.first(sp_.size()-1); }
|
// move
|
||||||
|
#ifndef GSL_MSVC_NO_DEFAULT_MOVE_CTOR
|
||||||
|
constexpr basic_zstring_span(basic_zstring_span&& other) = default;
|
||||||
|
#else
|
||||||
|
constexpr basic_zstring_span(basic_zstring_span&& other)
|
||||||
|
: span_(std::move(other.span_))
|
||||||
|
{}
|
||||||
|
#endif
|
||||||
|
|
||||||
constexpr string_span_type ensure_z() const noexcept { return gsl::ensure_z(sp_); }
|
// assign
|
||||||
|
constexpr basic_zstring_span& operator=(const basic_zstring_span& other) = default;
|
||||||
|
|
||||||
constexpr const_zstring_type assume_z() const noexcept { return sp_.data(); }
|
// move assign
|
||||||
|
#ifndef GSL_MSVC_NO_DEFAULT_MOVE_CTOR
|
||||||
|
constexpr basic_zstring_span& operator=(basic_zstring_span&& other) = default;
|
||||||
|
#else
|
||||||
|
constexpr basic_zstring_span& operator=(basic_zstring_span&& other)
|
||||||
|
{
|
||||||
|
span_ = std::move(other.span_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
constexpr bool empty() const noexcept { return span_.size() == 0; }
|
||||||
|
|
||||||
|
constexpr string_span_type as_string_span() const noexcept { return span_.first(span_.size()-1); }
|
||||||
|
|
||||||
|
constexpr string_span_type ensure_z() const noexcept { return gsl::ensure_z(span_); }
|
||||||
|
|
||||||
|
constexpr const_zstring_type assume_z() const noexcept { return span_.data(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
impl_type sp_;
|
impl_type span_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <size_t Max = dynamic_range>
|
template <size_t Max = dynamic_range>
|
||||||
|
Loading…
Reference in New Issue
Block a user