diff options
author | Alexander Gololobov <[email protected]> | 2022-02-10 16:47:37 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:47:37 +0300 |
commit | 39608cdb86363c75ce55b2b9a69841c3b71f22cf (patch) | |
tree | 4ec132c1665bd4d68e3628aa18d937c70d32413b /util/string/cast.cpp | |
parent | 54295b9bd4dc45c54d804084fd846d945148a7f0 (diff) |
Restoring authorship annotation for Alexander Gololobov <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'util/string/cast.cpp')
-rw-r--r-- | util/string/cast.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/util/string/cast.cpp b/util/string/cast.cpp index aa1e65a8e90..8c40983c848 100644 --- a/util/string/cast.cpp +++ b/util/string/cast.cpp @@ -640,9 +640,9 @@ DEF_FLT_SPEC(long double) #undef DEF_FLT_SPEC -// Using StrToD for float and double because it is faster than sscanf. +// Using StrToD for float and double because it is faster than sscanf. // Exception-free, specialized for float types -template <> +template <> bool TryFromStringImpl<double>(const char* data, size_t len, double& result) { if (!len) { return false; @@ -680,19 +680,19 @@ bool TryFromStringImpl<long double>(const char* data, size_t len, long double& r // Exception-throwing, specialized for float types template <> -double FromStringImpl<double>(const char* data, size_t len) { +double FromStringImpl<double>(const char* data, size_t len) { double d = 0.0; if (!TryFromStringImpl(data, len, d)) { ythrow TFromStringException() << TStringBuf("cannot parse float(") << TStringBuf(data, len) << TStringBuf(")"); - } - return d; -} - -template <> -float FromStringImpl<float>(const char* data, size_t len) { + } + return d; +} + +template <> +float FromStringImpl<float>(const char* data, size_t len) { return static_cast<float>(FromStringImpl<double>(data, len)); -} - +} + double StrToD(const char* b, const char* e, char** se) { struct TCvt: public StringToDoubleConverter { inline TCvt() |