Move output operators into target's namespace

This commit is contained in:
Danny Robson 2012-04-24 18:12:07 +10:00
parent 99bdd49f2f
commit ed990ba889
5 changed files with 15 additions and 11 deletions

View File

@ -35,7 +35,7 @@ colour::operator*= (double v) {
const json::node&
operator>> (const json::node &node, colour &c) {
util::operator>> (const json::node &node, colour &c) {
c.red = node[0].as_number ();
c.green = node[1].as_number ();
c.blue = node[2].as_number ();
@ -68,7 +68,7 @@ namespace util {
std::ostream&
operator<< (std::ostream &os, const util::colour &c) {
util::operator<< (std::ostream &os, const util::colour &c) {
os << "colour(" << c.red << ", " << c.green << ", " << c.blue << ", " << c.alpha << ")";
return os;
}

View File

@ -37,9 +37,10 @@ namespace util {
template <> colour& randomise (colour&);
template <> colour& random (void);
}
std::ostream& operator<< (std::ostream&, const util::colour&);
const json::node& operator>> (const json::node&, util::colour&);
}
#endif

View File

@ -25,7 +25,7 @@ main (int argc, char ** argv) {
try {
json::parse (boost::filesystem::path (argv[ARG_PATH]));
} catch (json::error &x) {
std::cerr << x.what () << std::endl;
std::cerr << "Error: " << x.what () << std::endl;
return EXIT_FAILURE;
}

View File

@ -193,19 +193,19 @@ vector::sanity (void) const {
util::vector
operator* (double a, const util::vector &b)
util::operator* (double a, const util::vector &b)
{ return b * a; }
std::ostream&
operator<< (std::ostream &os, const util::vector &v) {
util::operator<< (std::ostream &os, const util::vector &v) {
os << "vec(" << v.x << ", " << v.y << ", " << v.z << ")";
return os;
}
const json::node&
operator>> (const json::node &node, util::vector &v) {
util::operator>> (const json::node &node, util::vector &v) {
v.x = node[0].as_number ();
v.y = node[1].as_number ();
v.z = node[2].as_number ();

View File

@ -58,11 +58,14 @@ namespace util {
void sanity (void) const;
};
}
util::vector operator* (double, const util::vector&);
std::ostream& operator<< (std::ostream&, const util::vector&);
const json::node& operator>> (const json::node&, util::vector&);
}
#endif