diff options
author | David Percy <david.percy@mongodb.com> | 2021-01-06 19:51:09 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-04 10:12:54 +0000 |
commit | c7c16d3c6fdcb24bde8a014b0ca2c0d4650ce9d2 (patch) | |
tree | 71f67314e2c557364bcea3a93b229e7e2abcd7cb /src/mongo/base/string_data.h | |
parent | 6eea989f7996dea108f937990d62cd55d1f14c8c (diff) | |
download | mongo-c7c16d3c6fdcb24bde8a014b0ca2c0d4650ce9d2.tar.gz |
SERVER-53399 Parse individual window functions
Diffstat (limited to 'src/mongo/base/string_data.h')
-rw-r--r-- | src/mongo/base/string_data.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/base/string_data.h b/src/mongo/base/string_data.h index eb762771a77..bba986e9f66 100644 --- a/src/mongo/base/string_data.h +++ b/src/mongo/base/string_data.h @@ -90,6 +90,12 @@ public: StringData(const std::string& s) : StringData(s.data(), s.length(), TrustedInitTag()) {} /** + * Implicitly convert a std::string_view to a StringData. We can use the trusted + * init path because string_view::data() points to length() bytes of data. + */ + StringData(std::string_view s) : StringData(s.data(), s.length(), TrustedInitTag()) {} + + /** * Constructs a StringData with an explicit length. 'c' must * either be nullptr (in which case len must be zero), or be a * pointer into a character array. The StringData will refer to @@ -106,6 +112,13 @@ public: } /** + * Implicitly convert to a std::string_view. + */ + operator std::string_view() const { + return {rawData(), size()}; + } + + /** * Constructs a StringData with begin and end iterators. begin points to the beginning of the * string. end points to the position past the end of the string. In a null-terminated string, * end points to the null-terminator. |