ray: add ostream operator

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

12
ray.cpp
View File

@ -121,6 +121,18 @@ ray<S,T>::at (T t) const
} }
///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
std::ostream&
util::operator<< (std::ostream &os, ray<S,T> r)
{
return os << "ray(" << r.origin << ',' << r.direction << ')';
}
template std::ostream& util::operator<< (std::ostream&, ray<3,float>);
template std::ostream& util::operator<< (std::ostream&, ray<3,double>);
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
template struct util::ray<2,float>; template struct util::ray<2,float>;
template struct util::ray<3,float>; template struct util::ray<3,float>;

View File

@ -24,6 +24,8 @@
#include "sphere.hpp" #include "sphere.hpp"
#include "vector.hpp" #include "vector.hpp"
#include <iostream>
namespace util { namespace util {
template <size_t S, typename T> template <size_t S, typename T>
struct ray { struct ray {
@ -45,6 +47,8 @@ namespace util {
vector<S,T> direction; vector<S,T> direction;
}; };
template <size_t S, typename T>
std::ostream& operator<< (std::ostream&, ray<S,T>);
typedef ray<2,float> ray2f; typedef ray<2,float> ray2f;
typedef ray<3,float> ray3f; typedef ray<3,float> ray3f;