From 13a48e13bd7bdcfa7f87abb21a9ee49eb27665f9 Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Sun, 2 Jan 2022 12:40:02 -0800 Subject: [PATCH] [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. --- src/xenia/base/vec128.cc | 7 +++++++ src/xenia/base/vec128.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/xenia/base/vec128.cc b/src/xenia/base/vec128.cc index 70562dda1..5d91f7b5f 100644 --- a/src/xenia/base/vec128.cc +++ b/src/xenia/base/vec128.cc @@ -8,11 +8,13 @@ */ #include +#include #include #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 diff --git a/src/xenia/base/vec128.h b/src/xenia/base/vec128.h index cfba512a0..c9fc4cc13 100644 --- a/src/xenia/base/vec128.h +++ b/src/xenia/base/vec128.h @@ -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_