[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:
parent
f645c3ba31
commit
13a48e13bd
|
@ -8,11 +8,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "third_party/fmt/include/fmt/format.h"
|
#include "third_party/fmt/include/fmt/format.h"
|
||||||
#include "xenia/base/math.h"
|
#include "xenia/base/math.h"
|
||||||
#include "xenia/base/platform.h"
|
#include "xenia/base/platform.h"
|
||||||
|
#include "xenia/base/string_util.h"
|
||||||
#include "xenia/base/vec128.h"
|
#include "xenia/base/vec128.h"
|
||||||
|
|
||||||
namespace xe {
|
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);
|
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
|
} // namespace xe
|
||||||
|
|
|
@ -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::string to_string(const vec128_t& value);
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& os, const vec128_t& value);
|
||||||
|
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
||||||
#endif // XENIA_BASE_VEC128_H_
|
#endif // XENIA_BASE_VEC128_H_
|
||||||
|
|
Loading…
Reference in New Issue