matrix: move ostream operator into util namespace

This commit is contained in:
Danny Robson 2014-08-19 20:46:15 +10:00
parent 22dcf46c61
commit ea5f90dbf2
2 changed files with 29 additions and 22 deletions

View File

@ -405,26 +405,30 @@ namespace util {
}
//-----------------------------------------------------------------------------
template <typename T>
std::ostream&
operator<< (std::ostream &os, const matrix<T> &m) {
os << "{ {" << m.values[0][0] << ", "
<< m.values[0][1] << ", "
<< m.values[0][2] << ", "
<< m.values[0][3] << "}, "
<< "{" << m.values[1][0] << ", "
<< m.values[1][1] << ", "
<< m.values[1][2] << ", "
<< m.values[1][3] << "}, "
<< "{" << m.values[2][0] << ", "
<< m.values[2][1] << ", "
<< m.values[2][2] << ", "
<< m.values[2][3] << "}, "
<< "{" << m.values[3][0] << ", "
<< m.values[3][1] << ", "
<< m.values[3][2] << ", "
<< m.values[3][3] << "} }";
namespace util {
template <typename T>
std::ostream&
operator<< (std::ostream &os, const matrix<T> &m) {
os << "{ {" << m.values[0][0] << ", "
<< m.values[0][1] << ", "
<< m.values[0][2] << ", "
<< m.values[0][3] << "}, "
<< "{" << m.values[1][0] << ", "
<< m.values[1][1] << ", "
<< m.values[1][2] << ", "
<< m.values[1][3] << "}, "
<< "{" << m.values[2][0] << ", "
<< m.values[2][1] << ", "
<< m.values[2][2] << ", "
<< m.values[2][3] << "}, "
<< "{" << m.values[3][0] << ", "
<< m.values[3][1] << ", "
<< m.values[3][2] << ", "
<< m.values[3][3] << "} }";
return os;
return os;
}
}
template std::ostream& util::operator<< (std::ostream&, const matrix<float>&);
template std::ostream& util::operator<< (std::ostream&, const matrix<double>&);

View File

@ -59,9 +59,12 @@ namespace util {
static const matrix<T> IDENTITY;
static const matrix<T> ZEROES;
};
typedef matrix<float> matrixf;
template <typename T>
std::ostream& operator<< (std::ostream&, const util::matrix<T>&);
}
template <typename T>
std::ostream& operator<< (std::ostream&, const util::matrix<T>&);
#endif