Replies: 2 comments
-
|
to_chars/from_chars序列化浮点数虽然是C++17标准,但在gcc11/clang14附带的标准库中才支持。开发这个库时使用的编译器为gcc10/clang13。 后续可以考虑,如果支持to_chars则默认改用std::to_chars。如果需要更快的性能,或在低版本编译器上,可以切换回科学计数法格式。 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
现在也可以实现自定义float输出方式,参考这里: qicosmos/iguana#299 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
发现struct_json格式化浮点数时使用科学计数法,比如1.0格式化为"1E0",我的应用场景希望采用整数或小数表示,比如"1"或"1.0"。
调试代码,发现浮点数格式化的实现是在json_writer.hpp里调用了detail::to_chars。我尝试修改为std::to_chars后能够把1.0格式化为"1"。想请问既然struct_json要求C++17编译器,为什么不使用std::to_chars呢?
Beta Was this translation helpful? Give feedback.
All reactions