mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 18:56:19 +08:00
Avoid assuming that "std::string_view" is nullterminated. Generally it is really not. (#538)
Co-authored-by: ActuallyaDeviloper <ActuallyaDeviloper@users.noreply.github.com> Co-authored-by: Dr. Patrick Urbanke <patrick@getml.com>
This commit is contained in:
co-authored by
ActuallyaDeviloper
Dr. Patrick Urbanke
parent
36bc907d78
commit
8b2833b136
@@ -93,9 +93,9 @@ struct RFL_API Writer {
|
||||
|
||||
private:
|
||||
template <class T>
|
||||
std::string to_string(const T& _val) const {
|
||||
decltype(auto) to_string(const T& _val) const {
|
||||
if constexpr (std::is_same<std::remove_cvref_t<T>, std::string>()) {
|
||||
return _val;
|
||||
return _val; // Return reference to avoid expensive string copy.
|
||||
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
|
||||
return _val ? "true" : "false";
|
||||
} else if constexpr (std::is_floating_point<std::remove_cvref_t<T>>() ||
|
||||
|
||||
Reference in New Issue
Block a user