From 63a13ccb183cf34cc0909d4425f7ab3441456781 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 13 Feb 2016 19:15:14 +0900 Subject: [PATCH] src: Add constexpr to StringRef ctors --- src/template.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/template.h b/src/template.h index 1a48d787..3061ad52 100644 --- a/src/template.h +++ b/src/template.h @@ -387,19 +387,19 @@ public: using const_pointer = const value_type *; using const_iterator = const_pointer; - StringRef() : base(""), len(0) {} + constexpr StringRef() : base(""), len(0) {} explicit StringRef(const std::string &s) : base(s.c_str()), len(s.size()) {} explicit StringRef(const ImmutableString &s) : base(s.c_str()), len(s.size()) {} StringRef(const char *s) : base(s), len(strlen(s)) {} template - StringRef(const CharT *s, size_t n) + constexpr StringRef(const CharT *s, size_t n) : base(reinterpret_cast(s)), len(n) {} template StringRef(InputIt first, InputIt last) : base(first), len(std::distance(first, last)) {} template - static StringRef from_lit(const CharT(&s)[N]) { + constexpr static StringRef from_lit(const CharT(&s)[N]) { return StringRef(s, N - 1); } static StringRef from_maybe_nullptr(const char *s) {