diff --git a/colour.cpp b/colour.cpp index 1c5a368e..cbabf41f 100644 --- a/colour.cpp +++ b/colour.cpp @@ -382,12 +382,12 @@ namespace util { template std::ostream& util::operator<< (std::ostream &os, util::colour c) { - os << "colour("; + os << "["; std::transform (std::cbegin (c), std::cend (c), infix_iterator> (os, ", "), stream::to_numeric); - os << ")"; + os << "]"; return os; } diff --git a/coord/iostream.hpp b/coord/iostream.hpp index d5254a3e..3b6386fb 100644 --- a/coord/iostream.hpp +++ b/coord/iostream.hpp @@ -21,6 +21,7 @@ #include "../stream.hpp" #include +#include namespace util { template < diff --git a/extent.cpp b/extent.cpp index 3047dddc..6f64e4bb 100644 --- a/extent.cpp +++ b/extent.cpp @@ -232,25 +232,9 @@ template bool util::debug::valid (const extent<2,uint32_t>&); template bool util::debug::valid (const extent<2,uint64_t>&); -/////////////////////////////////////////////////////////////////////////////// -template -std::ostream& -util::operator<< (std::ostream &os, extent e) -{ - os << "["; - std::transform (std::cbegin (e.data), - std::cend (e.data), - infix_iterator> (os, ", "), - stream::to_numeric); - os << "]"; - return os; -} - - //----------------------------------------------------------------------------- -#define INSTANTIATE_S_T(S,T) \ -template struct util::extent; \ -template std::ostream& util::operator<< (std::ostream&, extent); +#define INSTANTIATE_S_T(S,T) \ +template struct util::extent; #define INSTANTIATE(T) \ INSTANTIATE_S_T(1,T) \ diff --git a/extent.hpp b/extent.hpp index 016545d8..ae220166 100644 --- a/extent.hpp +++ b/extent.hpp @@ -21,8 +21,6 @@ #include "vector.hpp" #include "point.hpp" -#include - namespace util { /** @@ -107,9 +105,6 @@ namespace util { using extent_range2i = extent_range2; using extent_range3u = extent_range2; - - template - std::ostream& operator<< (std::ostream&, util::extent); } diff --git a/fourcc.cpp b/fourcc.cpp index f0e3778a..8254e0e0 100644 --- a/fourcc.cpp +++ b/fourcc.cpp @@ -17,12 +17,11 @@ #include "fourcc.hpp" using util::fourcc; -using std::ostream; - static_assert (sizeof(fourcc) == 4, "fourcc must be a 4 byte POD"); +/////////////////////////////////////////////////////////////////////////////// fourcc fourcc::from_chars (uint8_t a, uint8_t b, uint8_t c, uint8_t d) { fourcc lhs; @@ -36,6 +35,7 @@ fourcc::from_chars (uint8_t a, uint8_t b, uint8_t c, uint8_t d) { } +//----------------------------------------------------------------------------- fourcc fourcc::from_string (const char data[4]) { fourcc lhs; @@ -49,6 +49,7 @@ fourcc::from_string (const char data[4]) { } +/////////////////////////////////////////////////////////////////////////////// bool fourcc::operator== (const char rhs[4]) const { return data[0] == rhs[0] && @@ -58,6 +59,7 @@ fourcc::operator== (const char rhs[4]) const { } +/////////////////////////////////////////////////////////////////////////////// fourcc::operator uint32_t (void) const { return static_cast (data[0] << 24U | data[1] << 16U | @@ -66,9 +68,9 @@ fourcc::operator uint32_t (void) const { } -ostream& -operator<< (ostream &os, fourcc f) { +/////////////////////////////////////////////////////////////////////////////// +std::ostream& +util::operator<< (std::ostream &os, fourcc f) { os << f.data[0] << f.data[1] << f.data[2] << f.data[3]; return os; } - diff --git a/fourcc.hpp b/fourcc.hpp index 8f26cbbd..abcec3ad 100644 --- a/fourcc.hpp +++ b/fourcc.hpp @@ -17,7 +17,7 @@ #ifndef __UTIL_FOURCC_HPP #define __UTIL_FOURCC_HPP -#include +#include #include namespace util { @@ -30,8 +30,9 @@ namespace util { bool operator== (const char[4]) const; operator uint32_t (void) const; }; + + std::ostream& operator<< (std::ostream&, util::fourcc); } -std::ostream& operator<< (std::ostream&, util::fourcc); #endif diff --git a/guid.hpp b/guid.hpp index 9993a706..c96cfbe5 100644 --- a/guid.hpp +++ b/guid.hpp @@ -18,7 +18,8 @@ #define __UTIL_GUID_HPP #include -#include +#include +#include class guid { public: diff --git a/quaternion.hpp b/quaternion.hpp index e6d77502..239d4f48 100644 --- a/quaternion.hpp +++ b/quaternion.hpp @@ -20,7 +20,7 @@ #include "vector.hpp" #include "matrix.hpp" -#include +#include namespace util { @@ -82,7 +82,8 @@ namespace util { typedef quaternion quaternionf; template - std::ostream& operator<< (std::ostream&, quaternion); + std::ostream& + operator<< (std::ostream&, quaternion); } diff --git a/region.cpp b/region.cpp index 26c6404b..72a5185a 100644 --- a/region.cpp +++ b/region.cpp @@ -365,8 +365,7 @@ util::region::UNIT (util::point{0}, util::extent{1}); template std::ostream& util::operator<< (std::ostream &os, const util::region &rhs) { - os << "region(" << rhs.p << ", " << rhs.e << ")"; - return os; + return os << "{position: " << rhs.p << ", extent: " << rhs.e << "}"; } diff --git a/region.hpp b/region.hpp index 12792f34..12e39c0b 100644 --- a/region.hpp +++ b/region.hpp @@ -23,6 +23,8 @@ #include "vector.hpp" #include "types/traits.hpp" +#include + namespace util { /** * A two-dimensional rectangle, with size and position. diff --git a/vector.cpp b/vector.cpp index a74674c1..d7352b95 100644 --- a/vector.cpp +++ b/vector.cpp @@ -248,21 +248,6 @@ util::vector::sanity (void) const /////////////////////////////////////////////////////////////////////////////// -// ostream - -template -std::ostream& -util::operator<< (std::ostream &os, util::vector v) -{ - os << "vec" << S << "(" << v.data[0]; - for (size_t i = 1; i < S; ++i) - os << ", " << v.data[i]; - os << ")"; - return os; -} - - -//----------------------------------------------------------------------------- template const json::tree::node& util::operator>> (const json::tree::node &node, util::vector &v) @@ -284,7 +269,6 @@ util::operator>> (const json::tree::node &node, util::vector &v) //----------------------------------------------------------------------------- #define INSTANTIATE_S_T(S,T) \ template struct util::vector; \ -template std::ostream& util::operator<< (std::ostream&, util::vector v); \ template const json::tree::node& util::operator>> (const json::tree::node&, util::vector&); diff --git a/vector.hpp b/vector.hpp index c7f6cf0d..a93baec8 100644 --- a/vector.hpp +++ b/vector.hpp @@ -21,7 +21,6 @@ #include "coord.hpp" #include -#include #include namespace util { @@ -67,8 +66,6 @@ namespace util { template vector<3,T> from_euler (vector<2,T>); // output and serialisation operators - template std::ostream& operator<< (std::ostream&, vector); - template const json::tree::node& operator>> (const json::tree::node&, vector&);