You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2018/07/03 12:56:33 UTC

[trafficserver] 01/03: TextView: Add constexpr literal constructor for std::string_view.

This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 0225210345ec575c4ddbe37ed011e16f6e61738e
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Mon Jul 2 20:34:08 2018 -0500

    TextView: Add constexpr literal constructor for std::string_view.
---
 lib/ts/TextView.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/ts/TextView.h b/lib/ts/TextView.h
index a1a688f..d4494cd 100644
--- a/lib/ts/TextView.h
+++ b/lib/ts/TextView.h
@@ -1018,3 +1018,13 @@ namespace std
 {
 ostream &operator<<(ostream &os, const ts::TextView &b);
 }
+
+// @c constexpr literal constructor for @c std::string_view
+// For unknown reasons, this enables creating @c constexpr constructs using @c std::string_view while the standard
+// one (""sv) does not.
+// I couldn't think of any better place to put this, so it's here. At least @c TextView is strongly related
+// to @c std::string_view.
+constexpr std::string_view operator"" _sv(const char *s, size_t n)
+{
+  return {s, n};
+}