Overloads to avoid writing float/double nans/infs.

This commit is contained in:
Robin E. R. Davies
2025-09-08 07:13:52 -04:00
parent c6b0f5f5a6
commit 128c62e25b
+25 -2
View File
@@ -410,7 +410,7 @@ namespace pipedal
{
write(string_view(s.c_str()));
}
void write(float f)
void write_float(float f)
{
if ((std::isnan(f) || std::isinf(f)))
{
@@ -426,7 +426,16 @@ namespace pipedal
os << std::setprecision(std::numeric_limits<float>::max_digits10) << f; // round-trip format
}
}
void write(double f)
void write(float f) {
write_float(f);
}
void write(float &f) {
write_float(f);
}
void write(const float &f) {
write_float(f);
}
void write_double(double f)
{
if ((std::isnan(f) || std::isinf(f)))
{
@@ -442,6 +451,20 @@ namespace pipedal
os << std::setprecision(std::numeric_limits<double>::max_digits10) << f; // round-trip format
}
}
void write(double d)
{
write_double(d);
}
void write(double &d)
{
write_double(d);
}
void write(const double &d)
{
write_double(d);
}
template <typename T>