I am using Eclipse 4.12.0 and Eclipse CDT 9.8.1 and I am writing C++ code that uses std::tuple
. Sometimes the code formatter introduces extra spaces in my code where I retrieve entries of tuples.
Please consider the following example file:
#include <tuple>
int main(int, char**)
{
std::tuple<int, int> myTuple; // First important line
std::get<0>(myTuple) = 2; // Second important line
return 0;
}
I have pasted here the code formatted by Eclipse. Everything is fine in this example. But when I copy and paste the two lines marked as important by the comments into another .cpp
file of my project and format them, the results is this:
std::tuple<int, int> myTuple; // First important line
std::get < 0 > (myTuple) = 2; // Second important line
The formatter has introduced spaces before and after the template angle brackets as if I would be doing a "greater than" or "lower than" comparison. This effect seems to somehow depend on the project. If it happens within a source file of one project in my project explorer, it seems to happen within every source file of that project. But as soon as I paste the lines into a source file of another project, the code formatter behaves correct (like in the example file given above).
I have not reported this as a bug, since I do not know how to make it reproducible. Does anyone have an idea what the reason might be? I have not enabled project specific code formatter settings, therefore it should not be a simple configuration error. Also adding or removing the line #include <tuple>
does not make a difference. What else could I try?