0

The data shows that alignof is used type-id, but why I can use Eigen::Matrix4f like below.

Eigen::Matrix4f t_localizer = ndt.getFinalTransformation();
std::cout << "t_localizer alignof: " << alignof(t_localizer);  // ??
std::cout << "t_localizer alignof: " << alignof(Eigen::Matrix4f); // valid

Both codes can compile and work!

daohu527
  • 452
  • 4
  • 15
  • @TedKleinBergman Is there some information or code to explain? – daohu527 May 08 '22 at 01:51
  • 1
    Allowing `alignof t_localizer` (braces are optional) is a gnu-extension. If you compile with `-Wpedantic` you get a warning: https://godbolt.org/z/jd9sxK96e – chtz May 09 '22 at 14:51
  • This is probably to allow the same syntax as `sizeof` (not sure why this is not allowed by the standard, though). – chtz May 09 '22 at 14:53

0 Answers0