summaryrefslogtreecommitdiff
path: root/source/core/slang-string.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/core/slang-string.h')
-rw-r--r--source/core/slang-string.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/core/slang-string.h b/source/core/slang-string.h
index b4583d0b2..65fd3a315 100644
--- a/source/core/slang-string.h
+++ b/source/core/slang-string.h
@@ -81,6 +81,10 @@ namespace Slang
public:
typedef UnownedStringSlice ThisType;
+ // Type to indicate that a ctor is with a length to disabmiguate 0/nullptr
+ // causing ambiguity.
+ struct WithLength {};
+
UnownedStringSlice()
: m_begin(nullptr)
, m_end(nullptr)
@@ -98,6 +102,10 @@ namespace Slang
: m_begin(b)
, m_end(b + len)
{}
+ UnownedStringSlice(WithLength, char const* b, size_t len)
+ : m_begin(b)
+ , m_end(b + len)
+ {}
SLANG_FORCE_INLINE char const* begin() const { return m_begin; }
@@ -190,6 +198,7 @@ namespace Slang
SLANG_FORCE_INLINE static UnownedStringSlice fromLiteral(const char (&in)[SIZE]) { return UnownedStringSlice(in, SIZE - 1); }
protected:
+
char const* m_begin;
char const* m_end;
};
@@ -216,6 +225,9 @@ namespace Slang
template <size_t SIZE>
SLANG_FORCE_INLINE static ThisType fromLiteral(const char(&in)[SIZE]) { return ThisType(in, SIZE - 1); }
+ /// Default constructor
+ UnownedTerminatedStringSlice():Super(Super::WithLength(), "", 0) {}
+
/// Note, b cannot be null because if it were then the string would not be null terminated
UnownedTerminatedStringSlice(char const* b)
: Super(b, b + strlen(b))