diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-09-16 23:02:22 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-09-16 23:02:22 +1000 |
commit | 090441b80aed3c7df45ff1a6d40ed56ee895ad28 (patch) | |
tree | 3a4a8137941aa60f0674d9ed9308a45266c96e4e /source/core/StarLexicalCast.cpp | |
parent | 40299558dd4585adb6066cdade5703be7cf10b76 (diff) |
make lexical casts (string -> int/float) faster
Diffstat (limited to 'source/core/StarLexicalCast.cpp')
-rw-r--r-- | source/core/StarLexicalCast.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/core/StarLexicalCast.cpp b/source/core/StarLexicalCast.cpp new file mode 100644 index 0000000..1387b2e --- /dev/null +++ b/source/core/StarLexicalCast.cpp @@ -0,0 +1,13 @@ +#include "StarLexicalCast.hpp" + +namespace Star { + +void throwLexicalCastError(std::errc ec, const char* first, const char* last) { + StringView str(first, last - first); + if (ec == std::errc::invalid_argument) + throw BadLexicalCast(strf("Lexical cast failed on '{}' (invalid argument)", str)); + else + throw BadLexicalCast(strf("Lexical cast failed on '{}'", str)); +} + +}
\ No newline at end of file |