[Base] Add `operator<<` string conversion for `vec128_t`

This allows `catch` to print out the contents of a particular vector when diagnosing how a `REQUIRE` expression has failed.
This commit is contained in:
Wunkolo 2022-01-02 12:40:02 -08:00 committed by Rick Gibbed
parent f645c3ba31
commit 13a48e13bd
2 changed files with 9 additions and 0 deletions

View File

@ -8,11 +8,13 @@
*/
#include <cstddef>
#include <ostream>
#include <string>
#include "third_party/fmt/include/fmt/format.h"
#include "xenia/base/math.h"
#include "xenia/base/platform.h"
#include "xenia/base/string_util.h"
#include "xenia/base/vec128.h"
namespace xe {
@ -21,4 +23,9 @@ std::string to_string(const vec128_t& value) {
return fmt::format("({}, {}, {}, {})", value.x, value.y, value.z, value.w);
}
std::ostream& operator<<(std::ostream& os, const vec128_t& value) {
os << string_util::to_hex_string(value);
return os;
}
} // namespace xe

View File

@ -257,6 +257,8 @@ static inline vec128_t vec128b(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3,
std::string to_string(const vec128_t& value);
std::ostream& operator<<(std::ostream& os, const vec128_t& value);
} // namespace xe
#endif // XENIA_BASE_VEC128_H_