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 class util::bezier<3>;
template class util::bezier<4>;
template <size_t S>
std::ostream&
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 <iostream>
namespace util {
template <size_t S>
class bezier {
@ -37,6 +39,9 @@ namespace util {
private:
point2f m_points[S+1];
};
template <size_t S>
std::ostream& operator<< (std::ostream&, const bezier<S>&);
}
#endif