Commit 74c2590f authored by Dominik Charousset's avatar Dominik Charousset

Allow conversion from const char* to string_view

parent 132614e9
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#pragma once #pragma once
#include <cstddef> #include <cstddef>
#include <cstring>
#include <iosfwd> #include <iosfwd>
#include <iterator> #include <iterator>
#include <limits> #include <limits>
...@@ -105,11 +106,10 @@ public: ...@@ -105,11 +106,10 @@ public:
// nop // nop
} }
template <size_t N> constexpr string_view(const char* cstr) noexcept
constexpr string_view(const char (&cstr)[N]) noexcept
: data_(cstr), : data_(cstr),
size_(N - 1) { size_(strlen(cstr)) {
static_assert(N > 0, ""); // nop
} }
constexpr string_view(const string_view&) noexcept = default; constexpr string_view(const string_view&) noexcept = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment