I assume the reason why you want to optimize this is that you need to print a lot of bounds in your program and it is tiresome to write like this, it is error prone etc.
In C, you could use a macro like this:
#define BOUNDS_FORMAT "%f-%f, %f-%f, %f-%f"
#define BOUNDS_ARG(b) b[0], b[1], b[2], b[3], b[4], b[5]
Then write it just like so:
printf(BOUNDS_FORMAT, BOUNDS_ARG(bounds));
// ... some other code, then another call, with more text around this time:
printf("Output of pass #%d: " BOUNDS_FORMAT "\n", passNumber, BOUNDS_ARG(bounds));
In C++, you are more expected to use std::cout
or similar stream. Then you could write a custom object to do this for you:
class PrintBounds {
protected:
const double* m_bounds;
public:
PrintBounds(const double* bounds)
: m_bounds(bounds)
{
}
friend std::ostream& operator<<(std::ostream& os, const PrintBounds& self)
{
os << self.m_bounds[0] << "-" << self.m_bounds[1] << ", "
<< self.m_bounds[2] << "-" << self.m_bounds[3] << ", "
<< self.m_bounds[3] << "-" << self.m_bounds[5];
return os;
}
};
Then you would use it like this:
std::cout << "Some other text: " << PrintBounds(bounds) << " ...\n";