diff options
author | Dmitry Potapov <potapov.d@gmail.com> | 2022-02-10 16:46:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:39 +0300 |
commit | 536101ea75c9ff5df10d01c2f460b1f6e12311b3 (patch) | |
tree | 115291277ad61b2cdcf5044d210fb103b5e1647e /util/string/cast.h | |
parent | 5036b5f2122001f9aef8a0e4cd85440d73ea6b9f (diff) | |
download | ydb-536101ea75c9ff5df10d01c2f460b1f6e12311b3.tar.gz |
Restoring authorship annotation for Dmitry Potapov <potapov.d@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/string/cast.h')
-rw-r--r-- | util/string/cast.h | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/util/string/cast.h b/util/string/cast.h index 90e925c194..f1e2f06abb 100644 --- a/util/string/cast.h +++ b/util/string/cast.h @@ -180,41 +180,41 @@ inline T FromString(const TUtf16String& s) { return ::FromString<T, wchar16>(s.data(), s.size()); } -namespace NPrivate { - template <typename TChar> - class TFromString { - const TChar* const Data; - const size_t Len; - - public: - inline TFromString(const TChar* data, size_t len) - : Data(data) - , Len(len) - { - } - - template <typename T> - inline operator T() const { - return FromString<T, TChar>(Data, Len); - } - }; -} - -template <typename TChar> -inline ::NPrivate::TFromString<TChar> FromString(const TChar* data, size_t len) { - return ::NPrivate::TFromString<TChar>(data, len); -} - -template <typename TChar> -inline ::NPrivate::TFromString<TChar> FromString(const TChar* data) { +namespace NPrivate { + template <typename TChar> + class TFromString { + const TChar* const Data; + const size_t Len; + + public: + inline TFromString(const TChar* data, size_t len) + : Data(data) + , Len(len) + { + } + + template <typename T> + inline operator T() const { + return FromString<T, TChar>(Data, Len); + } + }; +} + +template <typename TChar> +inline ::NPrivate::TFromString<TChar> FromString(const TChar* data, size_t len) { + return ::NPrivate::TFromString<TChar>(data, len); +} + +template <typename TChar> +inline ::NPrivate::TFromString<TChar> FromString(const TChar* data) { return ::NPrivate::TFromString<TChar>(data, std::char_traits<TChar>::length(data)); -} - -template <typename T> -inline ::NPrivate::TFromString<typename T::TChar> FromString(const T& s) { +} + +template <typename T> +inline ::NPrivate::TFromString<typename T::TChar> FromString(const T& s) { return ::NPrivate::TFromString<typename T::TChar>(s.data(), s.size()); -} - +} + // Conversion exception free versions template <typename T, typename TChar> bool TryFromStringImpl(const TChar* data, size_t len, T& result); |