bezier: add ostream operator

This commit is contained in:
Danny Robson 2015-01-22 14:56:19 +11:00
parent 436ae3db54
commit d63457c567
2 changed files with 25 additions and 3 deletions

View File

@ -270,6 +270,23 @@ util::bezier<S>::operator[] (size_t idx) const
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template class util::bezier<2>; template <size_t S>
template class util::bezier<3>; std::ostream&
template class util::bezier<4>; util::operator<< (std::ostream &os, const bezier<S> &b)
{
os << b[0];
for (size_t i = 1; i < S+1; ++i)
os << ", " << b[i];
return os;
}
//-----------------------------------------------------------------------------
#define INSTANTIATE(S) \
template class util::bezier<S>; \
template std::ostream& util::operator<< (std::ostream&, const bezier<S>&);
INSTANTIATE(1)
INSTANTIATE(2)
INSTANTIATE(3)

View File

@ -22,6 +22,8 @@
#include "point.hpp" #include "point.hpp"
#include <iostream>
namespace util { namespace util {
template <size_t S> template <size_t S>
class bezier { class bezier {
@ -37,6 +39,9 @@ namespace util {
private: private:
point2f m_points[S+1]; point2f m_points[S+1];
}; };
template <size_t S>
std::ostream& operator<< (std::ostream&, const bezier<S>&);
} }
#endif #endif