diff --git a/tdutils/td/utils/StringBuilder.h b/tdutils/td/utils/StringBuilder.h index 5491f8053..57fe5b9e0 100644 --- a/tdutils/td/utils/StringBuilder.h +++ b/tdutils/td/utils/StringBuilder.h @@ -39,9 +39,22 @@ class StringBuilder { return error_flag_; } - StringBuilder &operator<<(const char *str) { + template + std::enable_if_t>::value, StringBuilder> &operator<<(T str) { return *this << Slice(str); } + template + std::enable_if_t>::value, StringBuilder> &operator<<(T str) { + return *this << Slice(str); + } + + template + StringBuilder &operator<<(char (&str)[N]) = delete; + + template + StringBuilder &operator<<(const char (&str)[N]) { + return *this << Slice(str, N - 1); + } StringBuilder &operator<<(const wchar_t *str) = delete; @@ -94,11 +107,6 @@ class StringBuilder { StringBuilder &operator<<(const void *ptr); - template - StringBuilder &operator<<(const T *ptr) { - return *this << static_cast(ptr); - } - private: char *begin_ptr_; char *current_ptr_;