Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions absl/strings/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@
#include "absl/base/optimization.h"
#include "absl/base/port.h"

#ifdef ABSL_USES_STD_STRING_VIEW

#ifdef ABSL_HAVE_STD_STRING_VIEW
#include <string_view> // IWYU pragma: export
#endif

#ifdef ABSL_USES_STD_STRING_VIEW

namespace absl {
ABSL_NAMESPACE_BEGIN
Expand Down Expand Up @@ -201,6 +203,12 @@ class string_view {
constexpr string_view(const char* data, size_type len)
: ptr_(data), length_(CheckLengthInternal(len)) {}

#ifdef ABSL_HAVE_STD_STRING_VIEW
// Implicit constructor from std::string view
constexpr string_view(std::string_view str)
: ptr_(str.data ()), length_(CheckLengthInternal(str.size())) {}
#endif

// NOTE: Harmlessly omitted to work around gdb bug.
// constexpr string_view(const string_view&) noexcept = default;
// string_view& operator=(const string_view&) noexcept = default;
Expand Down