diff --git a/include/blt/parse/obj_loader.h b/include/blt/parse/obj_loader.h index c86e1bc..ea1d195 100644 --- a/include/blt/parse/obj_loader.h +++ b/include/blt/parse/obj_loader.h @@ -26,7 +26,7 @@ #include #include -namespace blt::gfx +namespace blt::parse { typedef blt::vec3f vertex_t; diff --git a/src/blt/parse/obj_loader.cpp b/src/blt/parse/obj_loader.cpp index 215dde3..a310d7b 100644 --- a/src/blt/parse/obj_loader.cpp +++ b/src/blt/parse/obj_loader.cpp @@ -27,8 +27,7 @@ #include "blt/std/utility.h" #include - -namespace blt::gfx +namespace blt::parse { class char_tokenizer { @@ -59,7 +58,20 @@ namespace blt::gfx T get(std::string_view str) { T x; +#if __cplusplus >= BLT_CPP20 const auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), x); +#else + auto ec = std::errc(); + if constexpr (std::is_floating_point_v) + { + x = static_cast(std::stod(std::string(str))); + } else if constexpr (std::is_integral_v) + { + x = static_cast(std::stoll(std::string(str))); + } else + static_assert( + "You are using a c++ version which does not support the required std::from_chars, manual conversion has failed to find a type!"); +#endif // probably not needed. if (ec != std::errc()) {