sphere: add ostream operator

This commit is contained in:
Danny Robson 2015-04-15 18:00:58 +10:00
parent bb15548fb6
commit b1263e8f14
2 changed files with 18 additions and 0 deletions

View File

@ -27,6 +27,19 @@ sphere<S,T>::sphere (point<S,T> _centre, T _radius):
CHECK_GE (_radius, 0);
}
//-----------------------------------------------------------------------------
template <size_t S, typename T>
std::ostream&
util::operator<< (std::ostream &os, sphere<S,T> 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>;

View File

@ -19,6 +19,8 @@
#include "point.hpp"
#include <iostream>
namespace util {
template <size_t S, typename T>
struct sphere {
@ -28,6 +30,9 @@ namespace util {
T radius;
};
template <size_t S, typename T>
std::ostream& operator<< (std::ostream&, sphere<S,T>);
typedef sphere<2,float> sphere2f;
typedef sphere<3,float> sphere3f;
}