matrix: use vector ostream operator
This commit is contained in:
parent
a0b0863d61
commit
c1036d8337
21
matrix.cpp
21
matrix.cpp
@ -342,24 +342,3 @@ util::to_euler (const matrix<Rows,Cols,T> &m)
|
||||
template util::vector<3,float> util::to_euler (const matrix<3,3,float>&);
|
||||
template util::vector<3,float> util::to_euler (const matrix<4,4,float>&);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <std::size_t Rows, std::size_t Cols, typename T>
|
||||
std::ostream&
|
||||
util::operator<< (std::ostream &os, const matrix<Rows,Cols,T> &m)
|
||||
{
|
||||
os << "{ ";
|
||||
|
||||
for (std::size_t i = 0; i < Rows; ++i) {
|
||||
os << "{ ";
|
||||
std::copy (std::cbegin (m[i]), std::cend (m[i]), util::infix_iterator<float> (os, ", "));
|
||||
os << ((i == Rows - 1) ? " }" : " }, ");
|
||||
}
|
||||
|
||||
return os << " }";
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template std::ostream& util::operator<< (std::ostream&, const matrix<4,4,float>&);
|
||||
template std::ostream& util::operator<< (std::ostream&, const matrix<4,4,double>&);
|
||||
|
19
matrix.hpp
19
matrix.hpp
@ -20,9 +20,10 @@
|
||||
#include "point.hpp"
|
||||
#include "range.hpp"
|
||||
#include "vector.hpp"
|
||||
#include "iterator.hpp"
|
||||
|
||||
#include <ostream>
|
||||
#include <cstdlib>
|
||||
#include <ostream>
|
||||
|
||||
namespace util {
|
||||
template <
|
||||
@ -469,9 +470,17 @@ namespace util {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <std::size_t Rows, std::size_t Cols, typename T>
|
||||
std::ostream& operator<< (std::ostream&, const matrix<Rows,Cols,T>&);
|
||||
|
||||
|
||||
}
|
||||
std::ostream&
|
||||
operator<< (std::ostream &os, const matrix<Rows,Cols,T> &m)
|
||||
{
|
||||
os << '[';
|
||||
std::copy (
|
||||
std::cbegin (m),
|
||||
std::cend (m),
|
||||
util::infix_iterator<decltype(m[0])> (os, ", ")
|
||||
);
|
||||
return os << ']';
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user