I want to be able to write the following:
std::format("My new box, Box({:.2},{:.2},{:.2})", box.getLength(), box.getWidth(), box.getHeight());
to
std::format("My new box, Box({:.2},{:.2},{:.2})", box.getLength(), box.getWidth(), box.getHeight());
This is what I've done so far:
template <>
class std::formatter<Box> :public std::formatter<double>
{
public:
using std::formatter<double>::format;
auto format(const Box& box, auto& context)
{
auto iter = format(box.getLength(), context);
context.advance(iter);
out = format(box.getWidth(), context);
context.advance(iter);
return format(box.getHeight(), context);
}
}; The box class definition is inside another header file. As you can see this code above does not work.