From 090441b80aed3c7df45ff1a6d40ed56ee895ad28 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 16 Sep 2024 23:02:22 +1000 Subject: make lexical casts (string -> int/float) faster --- source/core/StarLexicalCast.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 source/core/StarLexicalCast.cpp (limited to 'source/core/StarLexicalCast.cpp') 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 -- cgit v1.2.3