nholthaus / units

a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies.
http://nholthaus.github.io/units/
MIT License
952 stars 135 forks source link

Better output of compound units? #146

Open le-migou opened 6 years ago

le-migou commented 6 years ago

In v3.0.0.alpha-2, this

auto P = 1_MPa;
std::cout << P << '\n';

gives

1e+06 m^-1 kg s^-2

. Wouldn't something like

std::cout << P.value () << ' ' << abbreviation (P) << '\n';

that produces

1 MPa

be preferable ?

JohelEGP commented 6 years ago

Seems like a bug that it doesn't print the latter. If it has an UDL, then the abbreviation should be printed. But your output suggests that the streaming operator for ephemeral units is being used.

nholthaus commented 6 years ago

definitely a bug.

JohelEGP commented 3 years ago

Seems like #146 and this were fixed by #167, so in the v3.x branch the output is as expected. -- https://github.com/nholthaus/units/issues/195#issuecomment-429398567