diff --git a/include/rexy/detail/format/formatter.tpp b/include/rexy/detail/format/formatter.tpp index 81ac421..94dd735 100644 --- a/include/rexy/detail/format/formatter.tpp +++ b/include/rexy/detail/format/formatter.tpp @@ -30,7 +30,7 @@ #include "parse.hpp" #include "utf_iterator.hpp" -#include "../../utility.hpp" //abs +#include "../../utility.hpp" //abs, memcpy #include //remove_cvref #include //forward, move @@ -537,7 +537,14 @@ namespace rexy::fmt::detail{ break; }; - if(manual_precision){ + //manually handle nan and inf since some compilers (msvc) output something other than the desired values in 'to_chars' + if(is_nan){ + result.ptr = buffstart + 3; + rexy::memcpy(buffstart, "nan", 3); + }else if(is_infinity){ + result.ptr = buffstart + 3; + rexy::memcpy(buffstart, "inf", 3); + }else if(manual_precision){ const int precision = supplied_precision ? specs.precision : 6; result = std::to_chars(buffstart, buffend, f, fmt, precision); }else{ diff --git a/include/rexy/detail/format/output_buffer.hpp b/include/rexy/detail/format/output_buffer.hpp index 40eb2c2..ddd2549 100644 --- a/include/rexy/detail/format/output_buffer.hpp +++ b/include/rexy/detail/format/output_buffer.hpp @@ -114,6 +114,7 @@ namespace rexy::fmt::detail{ if(written != this->m_size){ REXY_THROW_FORMAT_ERROR("Failed to print data"); } + return written; } }; diff --git a/include/rexy/detail/format/parse.tpp b/include/rexy/detail/format/parse.tpp index b6b4b49..b1ba079 100644 --- a/include/rexy/detail/format/parse.tpp +++ b/include/rexy/detail/format/parse.tpp @@ -80,8 +80,8 @@ namespace rexy::fmt::detail::parse{ return static_cast(t); }else{ REXY_THROW_FORMAT_ERROR("Invalid dynamic specifier"); - return static_cast(0); } + return {}; } template constexpr decltype(auto) dynamic_width_adapter::operator()(void){ @@ -182,7 +182,6 @@ namespace rexy::fmt::detail::parse{ } } return last; - REXY_THROW_FORMAT_ERROR("Invalid index spec"); } for(auto it = start+1;it != last;++it){ if(!is_a_number(*it)){