From c9f8d5af69e3b0bb6c8e58e74b61c016b2d099a1 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 12 Apr 2018 23:27:35 +0000 Subject: Add AsSpan() convenience method to fxcrt strings. Make consistent with StringView methods. Change-Id: Idf336895053a327262de924b6a525052e22a25da Reviewed-on: https://pdfium-review.googlesource.com/30491 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- core/fxcrt/widestring.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/fxcrt/widestring.h') diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h index f6c24375a0..b668b0292c 100644 --- a/core/fxcrt/widestring.h +++ b/core/fxcrt/widestring.h @@ -79,6 +79,14 @@ class WideString { return WideStringView(c_str(), GetLength()); } + // Explicit conversion to span. + // Note: Any subsequent modification of |this| will invalidate the result. + pdfium::span AsSpan() const { + return m_pData ? pdfium::span(m_pData->m_String, + m_pData->m_nDataLength) + : pdfium::span(); + } + // Note: Any subsequent modification of |this| will invalidate iterators. const_iterator begin() const { return m_pData ? m_pData->m_String : nullptr; } const_iterator end() const { -- cgit v1.2.3