All Classes Files Functions Variables Typedefs Pages
Vector.hpp
Go to the documentation of this file.
1 #pragma once
2 
12 #include "VectorCore.hpp"
13 #include "RepCommon.hpp"
14 
15 #include <ostream>
16 #include <sstream>
17 #include <string>
18 
19 namespace lumina {
20 namespace internal {
21 
25 template <typename T, std::size_t N>
26 std::string vectorRep(Vector<T, N> in) {
27  std::stringstream ss;
28  ss << "Vec" << N << internal::typeCharRep<T>() << " {";
29 
30  for(int i = 0; i < N; ++i) {
31  if(i != 0)
32  ss << ", ";
33 
34  // handle special case 0 to 3 (x,y,z,w)
35  switch(i) {
36  case 0:
37  ss << "x => ";
38  break;
39  case 1:
40  ss << "y => ";
41  break;
42  case 2:
43  ss << "z => ";
44  break;
45  case 3:
46  ss << "w => ";
47  break;
48  }
49 
50  // append string representation of the element
51  ss << internal::numberToRep(in.data[i]);
52  }
53 
54  ss << "}";
55  return ss.str();
56 }
57 
58 } // namespace internal
59 
63 template <typename T, std::size_t N>
64 std::ostream& operator<<(std::ostream& out, const Vector<T, N>& vec) {
65  return (out << vectorRep(vec));
66 }
67 
68 } // namespace lumina
This file will define Vector and various vector functions.