diff --git a/sphere.cpp b/sphere.cpp index 827fc546..e8bb59be 100644 --- a/sphere.cpp +++ b/sphere.cpp @@ -27,6 +27,19 @@ sphere::sphere (point _centre, T _radius): CHECK_GE (_radius, 0); } + +//----------------------------------------------------------------------------- +template +std::ostream& +util::operator<< (std::ostream &os, sphere s) +{ + return os << "sphere(" << s.centre << ',' << s.radius << ')'; +} + +template std::ostream& util::operator<< (std::ostream&, sphere<2,float>); +template std::ostream& util::operator<< (std::ostream&, sphere<3,float>); + + //----------------------------------------------------------------------------- template struct util::sphere<2,float>; template struct util::sphere<3,float>; diff --git a/sphere.hpp b/sphere.hpp index 2896d64d..124d691f 100644 --- a/sphere.hpp +++ b/sphere.hpp @@ -19,6 +19,8 @@ #include "point.hpp" +#include + namespace util { template struct sphere { @@ -28,6 +30,9 @@ namespace util { T radius; }; + template + std::ostream& operator<< (std::ostream&, sphere); + typedef sphere<2,float> sphere2f; typedef sphere<3,float> sphere3f; }