'clang-format for Eigen matrix initialization
To inialize for example Eigen::Matrix3i
we can use syntax:
Eigen::Matrix3i T;
T << 1, 0, 0,
0, 2, 0,
0, 0, 3;
However, when using clang-format
(3.6 in my case) with Google
style this nice initialization turns into:
Eigen::Matrix3i T;
T << 1, 0, 0, 0, 2, 0, 0, 0, 3;
Is there an easy way to avoid this? Is there a way to tell clang-format
to skip something like this?
Solution 1:[1]
It looks like your only option is to use a rather ugly clang-format switching syntax:
Eigen::Matrix3i T;
// clang-format off
T << 1, 0, 0,
0, 2, 0,
0, 0, 3;
// clang-format on
Solution 2:[2]
Did you try this?
Eigen::Matrix3i T;
T << 1, 0, 0, //
0, 2, 0, //
0, 0, 3; //
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | yuyoyuppe |
Solution 2 | Joan SolĂ |