From 1106e1e6358367296e3b820af5d40888c14b4254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Thu, 14 Sep 2023 08:44:03 -0400 Subject: [PATCH] [cross] Add fix in case from_chars(double) is not there --- include/avnd/binding/max/from_atoms.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/avnd/binding/max/from_atoms.hpp b/include/avnd/binding/max/from_atoms.hpp index ccca8057..8791d327 100644 --- a/include/avnd/binding/max/from_atoms.hpp +++ b/include/avnd/binding/max/from_atoms.hpp @@ -2,7 +2,11 @@ #include #include +#if !defined(__cpp_lib_to_chars) +#include +#else #include +#endif #include #include @@ -35,12 +39,20 @@ struct from_atom if(sym && sym->s_name) { double vv{}; + #if defined(__cpp_lib_to_chars) auto [_, ec] = std::from_chars(sym->s_name, sym->s_name + strlen(sym->s_name), vv); if(ec == std::errc{}) { v = vv; return true; } + #else + if(boost::conversion::try_lexical_convert(str, vv)) + { + v = vv; + return true; + } + #endif } return false; }