sphere: add ostream operator
This commit is contained in:
parent
bb15548fb6
commit
b1263e8f14
13
sphere.cpp
13
sphere.cpp
@ -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>;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user