diff options
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/string.h | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/zencore/include/zencore/string.h b/zencore/include/zencore/string.h index 7af27ca20..a43d57327 100644 --- a/zencore/include/zencore/string.h +++ b/zencore/include/zencore/string.h @@ -219,6 +219,19 @@ public: return AppendRange(String.data(), String.data() + String.size()); } + inline StringBuilderImpl& AppendBool(bool v) + { + // This is a method instead of a << operator overload as the latter can + // easily get called with non-bool types like pointers. It is a very + // subtle behaviour that can cause bugs. + using namespace std::literals; + if (v) + { + return AppendAscii("true"sv); + } + return AppendAscii("false"sv); + } + inline void RemoveSuffix(uint32_t Count) { ZEN_ASSERT(Count <= Size()); @@ -291,15 +304,6 @@ public: inline StringBuilderImpl& operator<<(const char* str) { return AppendAscii(str); } inline StringBuilderImpl& operator<<(const std::string_view str) { return AppendAscii(str); } inline StringBuilderImpl& operator<<(const std::u8string_view str) { return AppendAscii(str); } - inline StringBuilderImpl& operator<<(bool v) - { - using namespace std::literals; - if (v) - { - return AppendAscii("true"sv); - } - return AppendAscii("false"sv); - } protected: inline void Init(C* Base, size_t Capacity) |