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:
ActuallyaDeviloper
2025-12-06 18:53:45 +01:00
committed by GitHub
co-authored by ActuallyaDeviloper Dr. Patrick Urbanke
parent 36bc907d78
commit 8b2833b136
11 changed files with 52 additions and 43 deletions
+2 -2
View File
@@ -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>>() ||