| Index: compiled/String.h |
| diff --git a/compiled/String.h b/compiled/String.h |
| index 70086f847b913460c906d285ff85c9f8013f8a67..de3d2021ef32fafccc70e2b5c05d8421c417bb2b 100644 |
| --- a/compiled/String.h |
| +++ b/compiled/String.h |
| @@ -76,14 +76,12 @@ protected: |
| value_type* mBuf; |
| size_type mLen; |
| - explicit String(value_type* buf, size_type len, size_type flags) |
| + constexpr explicit String(value_type* buf, size_type len, size_type flags) |
| : mBuf(buf), mLen((len & LENGTH_MASK) | flags) |
| { |
| } |
| - ~String() |
| - { |
| - } |
| + ~String() = default; |
|
Eric
2018/03/15 17:05:00
We're not defining copy or move constructors, so t
René Jeschke
2018/03/15 17:41:23
What was the reason to make the dtor protected in
Eric
2018/03/15 18:33:54
Don't know. If there's a good reason, it deserves
sergei
2018/03/16 13:43:26
Such class hierarchy caused questions from the beg
|
| void reset(value_type* buf, size_type len, size_type flags) |
| { |
| @@ -92,17 +90,17 @@ protected: |
| } |
| public: |
| - size_type length() const |
| + constexpr size_type length() const |
|
Eric
2018/03/15 17:05:00
constexpr implies const, so the trailing declarati
René Jeschke
2018/03/15 17:41:23
No, it does not. 'constexpr' on an object declarat
Eric
2018/03/15 18:33:54
Bah. Misread the spec. Never mind.
|
| { |
| return mLen & LENGTH_MASK; |
| } |
| - bool empty() const |
| + constexpr bool empty() const |
| { |
| return !(mLen & LENGTH_MASK); |
| } |
| - const value_type* data() const |
| + constexpr const value_type* data() const |
| { |
| return mBuf; |
| } |
| @@ -113,7 +111,7 @@ public: |
| return mBuf; |
| } |
| - const value_type& operator[](size_type pos) const |
| + constexpr const value_type& operator[](size_type pos) const |
| { |
| return mBuf[pos]; |
| } |
| @@ -124,7 +122,7 @@ public: |
| return mBuf[pos]; |
| } |
| - bool is_writable() const |
| + constexpr bool is_writable() const |
| { |
| return (mLen & FLAGS_MASK) == READ_WRITE; |
| } |
| @@ -194,12 +192,12 @@ public: |
| return npos; |
| } |
| - bool is_invalid() const |
| + constexpr bool is_invalid() const |
| { |
| return (mLen & FLAGS_MASK) == INVALID; |
| } |
| - bool is_deleted() const |
| + constexpr bool is_deleted() const |
| { |
| return (mLen & FLAGS_MASK) == DELETED; |
| } |
| @@ -245,17 +243,23 @@ inline std::ostream& operator<<(std::ostream& os, const String& str) |
| class DependentString : public String |
| { |
| public: |
| - explicit DependentString() |
| + constexpr explicit DependentString() |
| : String(nullptr, 0, INVALID) |
| { |
| } |
| + template <int N1> |
| + constexpr explicit DependentString(const value_type (&buf)[N1]) |
| + : String(const_cast<value_type*>(buf), N1 - 1, READ_ONLY) |
| + { |
| + } |
| + |
| explicit DependentString(value_type* buf, size_type len) |
| : String(buf, len, READ_WRITE) |
| { |
| } |
| - explicit DependentString(const value_type* buf, size_type len) |
| + constexpr explicit DependentString(const value_type* buf, size_type len) |
| : String(const_cast<value_type*>(buf), len, READ_ONLY) |
| { |
| } |
| @@ -313,7 +317,7 @@ inline std::ostream& operator<<(std::ostream& os, const DependentString& str) |
| } |
| #endif |
| -inline DependentString operator "" _str(const String::value_type* str, |
| +inline constexpr DependentString operator "" _str(const String::value_type* str, |
|
Eric
2018/03/15 17:05:01
constexpr on functions implies inline, so it could
René Jeschke
2018/03/15 17:41:23
Right. Done.
|
| String::size_type len) |
| { |
| return DependentString(str, len); |