I write this tiny C++ example in Eclipse 3.4.1 (CDT 5.0.1):
#include <iostream>
#include <vector>
#include <boost/foreach.hpp>
int foo()
{
std::vector<int> numbers;
BOOST_FOREACH(int n, numbers)
{
std::cout << n << std::endl;
}
std::cout << numbers.size << std::endl;
}
Then I hit Shift+Ctrl+F to format my code, and it becomes:
#include <iostream>
#include <vector>
#include <boost/foreach.hpp>
int foo()
{
std::vector<int> numbers;
BOOST_FOREACH(int n, numbers)
{ std::cout << n << std::endl;
}
std::cout << numbers.size << std::endl;
}
This is with the BSD/Allman Code Style. Other styles obviously vary the look of the formatted code, but none give correct indentation.
When I use the format feature on a larger piece of code, subsequent functions or methods are also affected by too little indentation, making the formatting help pretty unhelpful.
Is there something I can do to make the indentation work properly with BOOST_FOREACH?