tint/utils: Add operator<<() support to vector

Helpful for tests and the like.

Change-Id: I07f8c59af6db4d6a5629dca2dc985398b75eccf9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111760
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-11-25 14:53:23 +00:00
committed by Dawn LUCI CQ
parent 541ea4bb02
commit c572df265d
5 changed files with 90 additions and 8 deletions

View File

@@ -18,6 +18,7 @@
#include <stdint.h>
#include <functional>
#include <ostream>
#include "src/tint/reflection.h"
#include "src/tint/utils/hash.h"
@@ -47,6 +48,14 @@ struct BindingPoint {
inline bool operator!=(const BindingPoint& rhs) const { return !(*this == rhs); }
};
/// Prints the BindingPoint @p bp to @p o
/// @param o the std::ostream to write to
/// @param bp the BindingPoint
/// @return the std::ostream so calls can be chained
inline std::ostream& operator<<(std::ostream& o, const BindingPoint& bp) {
return o << "[group: " << bp.group << ", binding: " << bp.binding << "]";
}
} // namespace tint::sem
namespace std {

View File

@@ -17,6 +17,7 @@
#include <cstdint>
#include <functional>
#include <ostream>
#include "src/tint/sem/binding_point.h"
@@ -43,6 +44,15 @@ struct SamplerTexturePair {
inline bool operator!=(const SamplerTexturePair& rhs) const { return !(*this == rhs); }
};
/// Prints the SamplerTexturePair @p stp to @p o
/// @param o the std::ostream to write to
/// @param stp the SamplerTexturePair
/// @return the std::ostream so calls can be chained
inline std::ostream& operator<<(std::ostream& o, const SamplerTexturePair& stp) {
return o << "[sampler: " << stp.sampler_binding_point
<< ", texture: " << stp.sampler_binding_point << "]";
}
} // namespace tint::sem
namespace std {