diff options
author | sereglond <sereglond@yandex-team.ru> | 2022-02-10 16:47:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:46 +0300 |
commit | eb3d925534734c808602b31b38b953677f0a279f (patch) | |
tree | 4222ef8dc375ee9f30b68a004ee42a0845e005b6 /util/string/cast.h | |
parent | 4c8065245df3ea26b7757bcb1f8218df287f9148 (diff) | |
download | ydb-eb3d925534734c808602b31b38b953677f0a279f.tar.gz |
Restoring authorship annotation for <sereglond@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/string/cast.h')
-rw-r--r-- | util/string/cast.h | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/util/string/cast.h b/util/string/cast.h index 90e925c194..3d970ea2d8 100644 --- a/util/string/cast.h +++ b/util/string/cast.h @@ -311,18 +311,18 @@ inline T FromStringWithDefault(const TStringType& s) { double StrToD(const char* b, char** se); double StrToD(const char* b, const char* e, char** se); -template <int base, class T> -size_t IntToString(T t, char* buf, size_t len); - -template <int base, class T> +template <int base, class T> +size_t IntToString(T t, char* buf, size_t len); + +template <int base, class T> inline TString IntToString(T t) { static_assert(std::is_arithmetic<std::remove_cv_t<T>>::value, "expect std::is_arithmetic<std::remove_cv_t<T>>::value"); - - char buf[256]; - + + char buf[256]; + return TString(buf, IntToString<base>(t, buf, sizeof(buf))); -} - +} + template <int base, class TInt, class TChar> bool TryIntFromString(const TChar* data, size_t len, TInt& result); @@ -331,18 +331,18 @@ inline bool TryIntFromString(const TStringType& s, TInt& result) { return TryIntFromString<base>(s.data(), s.size(), result); } -template <class TInt, int base, class TChar> -TInt IntFromString(const TChar* str, size_t len); - -template <class TInt, int base, class TChar> -inline TInt IntFromString(const TChar* str) { +template <class TInt, int base, class TChar> +TInt IntFromString(const TChar* str, size_t len); + +template <class TInt, int base, class TChar> +inline TInt IntFromString(const TChar* str) { return IntFromString<TInt, base>(str, std::char_traits<TChar>::length(str)); -} - +} + template <class TInt, int base, class TStringType> inline TInt IntFromString(const TStringType& str) { return IntFromString<TInt, base>(str.data(), str.size()); -} +} static inline TString ToString(const TStringBuf str) { return TString(str); |