From 5205b56d23e327b9e0fb74dbbe158e11043f3f2e Mon Sep 17 00:00:00 2001 From: Samin Date: Tue, 1 Oct 2024 17:59:27 +0200 Subject: [PATCH] Handle unsupported result types when casting strings. --- src/runtime/local/kernels/CastSca.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/runtime/local/kernels/CastSca.h b/src/runtime/local/kernels/CastSca.h index 73fcce5f4..9d2ae703f 100644 --- a/src/runtime/local/kernels/CastSca.h +++ b/src/runtime/local/kernels/CastSca.h @@ -86,6 +86,15 @@ struct CastSca { else if constexpr(std::is_same::value) return static_cast(std::stof(arg)); + else { + // Trigger a compiler warning using deprecated attribute + return unsupported_type(arg); + } + } + + [[deprecated("CastSca: Warning! Unsupported result type in casting string values.")]] + static VTRes unsupported_type(std::string arg) { + throw std::runtime_error("CastSca: Unsupported result type in casting string values"); } }; @@ -100,6 +109,15 @@ struct CastSca { else if constexpr(std::is_same::value) return static_cast(std::stof(arg.buffer)); + else { + // Trigger a compiler warning using deprecated attribute + return unsupported_type(arg); + } + } + + [[deprecated("CastSca: Warning! Unsupported result type in casting string values.")]] + static VTRes unsupported_type(std::string arg) { + throw std::runtime_error("CastSca: Unsupported result type in casting string values"); } };