fork(1) download
  1. #include <Eigen/Core>
  2.  
  3. #include <vector>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7. using namespace Eigen;
  8.  
  9. template <typename T>
  10. void log_alignment(const T* t)
  11. {
  12. unsigned long long address = reinterpret_cast<unsigned long long>(t);
  13.  
  14. int max_alignment_check = 256;
  15. for (; max_alignment_check>1; max_alignment_check/=2)
  16. {
  17. if (address % max_alignment_check == 0)
  18. break;
  19. }
  20.  
  21. std::cout << "Address 0x" << std::hex << address << " is " << std::dec << max_alignment_check << " bit aligned.\n";
  22. }
  23.  
  24. struct B
  25. {
  26. char c;
  27. Vector4f a;
  28. };
  29.  
  30. int main()
  31. {
  32. B b;
  33. B* b_ptr = new B;
  34. B* b_arr = new B[10];
  35. std::vector<B> b_vec(10);
  36.  
  37. log_alignment(&b);
  38. log_alignment(b_ptr);
  39. log_alignment(b_arr);
  40. log_alignment(b_vec.data());
  41. }
  42.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:22: fatal error: Eigen/Core: No such file or directory
 #include <Eigen/Core>
                      ^
compilation terminated.
stdout
Standard output is empty