//concern here is that there might be Many versions?
template<typename... Args>
struct num_elements
{
static const int value = sizeof...(Args);
};
//separate v from the pack in order to deduce m
//why can't v be an rvalue reference?
//as such the args pack is one less than the number of vectors so we need to increment our returned number of arguments
template<typename... Args, typename T, int m = ++num_elements<Args...>::value, int n>
Matrix<T,m,n> rowMatrix(vector<T, n>& v, Args&&... args)
{
Matrix<T,m,n> mat;
_rowMatrix<T, m, n>(0, mat, v, args...);
return mat;
}
//actually doing the work
template<typename T, int m, int n, typename... Args>
inline void _rowMatrix(int c, Matrix<T, m, n>& mat, vector<T, n>& v, Args&&... vectors)
{
for(int i = 0; i < n; i++)
mat.data[c * Matrix<T,m,n>::colOffset + i * Matrix<T,m,n>::rowOffset] = v[i];
_rowMatrix(++c, mat, vectors...);
}
//terminating condition
template<typename T, int m, int n, typename... Args>
inline void _rowMatrix(int c, Matrix<T, m, n>& mat) {}