diff options
author | crupest <crupest@outlook.com> | 2022-01-12 02:30:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-01-12 02:30:25 +0800 |
commit | 882d843083895f4905571dc273e801ee18fd5984 (patch) | |
tree | 163890b8ccb64b8eff28af558ac803affe392488 /include/cru/common/String.hpp | |
parent | 01f98ce88950cdb729f5db58bf26f2fffa1c326c (diff) | |
download | cru-882d843083895f4905571dc273e801ee18fd5984.tar.gz cru-882d843083895f4905571dc273e801ee18fd5984.tar.bz2 cru-882d843083895f4905571dc273e801ee18fd5984.zip |
...
Diffstat (limited to 'include/cru/common/String.hpp')
-rw-r--r-- | include/cru/common/String.hpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/include/cru/common/String.hpp b/include/cru/common/String.hpp index 8acb6a87..88dd06f0 100644 --- a/include/cru/common/String.hpp +++ b/include/cru/common/String.hpp @@ -328,16 +328,16 @@ std::enable_if_t<std::is_integral_v<T>, String> ToString(T value) { auto result = std::to_chars(buffer.data(), buffer.data() + buffer.size(), value); + if (result.ec == std::errc{}) { + } else { + throw std::invalid_argument("Failed to convert value to chars."); + } + auto size = result.ptr - buffer.data(); auto b = new char16_t[size + 1]; b[size] = 0; std::copy(buffer.data(), result.ptr, b); return String::FromBuffer(b, size, size); - - if (result.ec == std::errc{}) { - } else { - throw std::invalid_argument("Failed to convert value to chars."); - } } template <typename T> @@ -346,7 +346,7 @@ std::enable_if_t<std::is_floating_point_v<T>, String> ToString(T value) { return String(str.cbegin(), str.cend()); } -inline String ToString(String value) { return std::move(value); } +inline String ToString(String value) { return value; } namespace details { enum class FormatTokenType { PlaceHolder, Text }; @@ -366,7 +366,7 @@ template <typename TA, typename... T> void FormatAppendFromFormatTokenList( String& current, const std::vector<FormatToken>& format_token_list, Index index, TA&& args0, T&&... args) { - for (Index i = index; i < format_token_list.size(); i++) { + for (Index i = index; i < static_cast<Index>(format_token_list.size()); i++) { const auto& token = format_token_list[i]; if (token.type == FormatTokenType::PlaceHolder) { current += ToString(std::forward<TA>(args0)); |