#pragma once #include #include "StringUtil.h" template class String { CharType _buffer[MaxLength + 1]; public: String() { _buffer[0] = 0; } template>> String(const T* const & str) { StringUtil::Copy(_buffer, str, MaxLength + 1); } explicit String(const char* str) { StringUtil::Copy(_buffer, str, MaxLength + 1); } template constexpr String(const CharType(&str)[N]) { if (N * sizeof(CharType) <= sizeof(_buffer)) memcpy(_buffer, str, N * sizeof(CharType)); else { memcpy(_buffer, str, MaxLength * sizeof(CharType)); _buffer[MaxLength] = 0; } } template>> void operator=(const T* const & str) { StringUtil::Copy(_buffer, str, MaxLength + 1); } template constexpr void operator=(const CharType(&str)[N]) { if (N * sizeof(CharType) <= sizeof(_buffer)) memcpy(_buffer, str, N * sizeof(CharType)); else { memcpy(_buffer, str, MaxLength * sizeof(CharType)); _buffer[MaxLength] = 0; } } constexpr operator const CharType*() const { return _buffer; } constexpr const CharType* GetString() const { return _buffer; } };