0

Today I used boost-units for the first time and I was really satisfied with the outcome.

Unfortunately, I'm not completely satisfied with the display of the operator<< for a given unit.

The following code prints m s^-2 on the console:

#include <boost/units/systems/si/acceleration.hpp>
#include <boost/units/io.hpp>
#include <iostream>

int main(int argc, char**args) {
    using namespace boost::units;
    using namespace boost::units::si;

    std::cout << acceleration() << std::endl;

    return 0;
}

I'm wondering if there is an easy way to change the output to something like m/(s^2) or even m/s^2. I think, that this kind of representation might be easier to read.

Aleph0
  • 5,816
  • 4
  • 29
  • 80
  • Have you considered writing your own? That would give you total control over formatting. – Logicrat Jul 05 '16 at 12:48
  • The problem is that there may be ambiguities in the representation, particularly with fractional exponents. Formatting for `ostream` is probably only a good idea for logging or debugging purposes, and there it is just a matter of practice. – rodrigo Jul 05 '16 at 12:57

0 Answers0