Increase precision of sf::Rect<T> operator<<

This has been a recurring problem. I had to add similar code to the
sf::Angle operator<< because I was getting tiny floating point
differences that after rounding were imperceptable.
This commit is contained in:
Chris Thrasher 2022-03-06 12:43:48 -07:00 committed by Lukas Dürrenberger
parent cf155fbb1b
commit 2adc3c0e23

View File

@ -9,6 +9,8 @@
#include "WindowUtil.hpp"
#include <SFML/Graphics/Rect.hpp>
#include <iomanip>
#include <limits>
namespace sf
{
@ -23,7 +25,10 @@ namespace sf
template <typename T>
std::ostream& operator <<(std::ostream& os, const sf::Rect<T>& rect)
{
const auto flags = os.flags();
os << std::fixed << std::setprecision(std::numeric_limits<T>::max_digits10);
os << "(left=" << rect.left << ", top=" << rect.top << ", width=" << rect.width << ", height=" << rect.height << ")";
os.flags(flags);
return os;
}
}