Skip to content
Snippets Groups Projects
Commit 85a4a3f9 authored by Martin Wölzer's avatar Martin Wölzer
Browse files

src/include/clapp/value.hpp: updated implementation of value::to_string to use...

src/include/clapp/value.hpp: updated implementation of value::to_string to use less std::stringstreams
parent 76fb64bc
No related branches found
No related tags found
1 merge request!24Create release v.0.6.0
...@@ -48,15 +48,15 @@ constexpr const char* clapp::value::get_chrono_postfix() noexcept { ...@@ -48,15 +48,15 @@ constexpr const char* clapp::value::get_chrono_postfix() noexcept {
template <typename T> template <typename T>
std::string clapp::value::to_string(const T& value) { std::string clapp::value::to_string(const T& value) {
std::stringstream string_stream;
if constexpr (std::is_integral_v<T>) { if constexpr (std::is_integral_v<T>) {
string_stream << std::to_string(value); return std::to_string(value);
} else if constexpr (type_traits::is_chrono_duration<T>::value) { } else if constexpr (type_traits::is_chrono_duration<T>::value) {
string_stream << value.count() << get_chrono_postfix<T>(); return std::to_string(value.count()) + get_chrono_postfix<T>();
} else { } else {
std::stringstream string_stream;
string_stream << value; string_stream << value;
return string_stream.str();
} }
return string_stream.str();
} }
template <typename T> template <typename T>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment