diff options
author | U. Artie Eoff <ullysses.a.eoff@intel.com> | 2016-10-26 13:24:18 -0700 |
---|---|---|
committer | Sean V Kelley <seanvk@posteo.de> | 2016-10-28 13:12:26 -0700 |
commit | 2bbdc90be2f41198619c073ce1409dc5c64334dc (patch) | |
tree | d59de776999c4416383387f77d37e663d258ea86 /test | |
parent | fd26aa497dff3361e31e3d99066915a34a67ae64 (diff) |
test: streamable valarray
Add stream operators for std::valarray.
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
Reviewed-by: Sean V Kelley <seanvk@posteo.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/i965_streamable.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/i965_streamable.h b/test/i965_streamable.h index 4969c14..0f7e129 100644 --- a/test/i965_streamable.h +++ b/test/i965_streamable.h @@ -29,6 +29,7 @@ #include <iostream> #include <iomanip> #include <sstream> +#include <valarray> #include <va/va.h> namespace std { @@ -55,6 +56,30 @@ namespace std { } return os << std::dec << "}"; } + + template <typename T> inline std::ostream& + operator<<(std::ostream& os, const std::valarray<T>& a) + { + os << "{"; + for (const auto& s : a) { + if (&s != &a[0]) + os << ","; + os << s; + } + return os << "}"; + } + + template <> inline std::ostream& + operator<<(std::ostream& os, const std::valarray<uint8_t>& a) + { + os << "{" << std::hex; + for (const auto& s : a) { + if (&s != &a[0]) + os << ","; + os << "0x" << std::setfill('0') << std::setw(2) << unsigned(s); + } + return os << std::dec << "}"; + } }// namespace std template <typename T> |