units icon indicating copy to clipboard operation
units copied to clipboard

Fold operator<<

Open JohelEGP opened this issue 5 years ago • 2 comments

https://github.com/nholthaus/units/blob/1a3164e1905744b3b78466438dccdc00e3f1dadb/include/units/core.h#L190-L218

This can be done away with if, at https://github.com/nholthaus/units/blob/1a3164e1905744b3b78466438dccdc00e3f1dadb/include/units/core.h#L2532-L2550

unit_abbreviation_v is used. Then there'd be ~5 operator<<s in the library, rather than 5 + 1 per unit.

JohelEGP avatar Oct 05 '20 22:10 JohelEGP

The only thing I want to double check is that I think that function's purpose was to boil down undefined ephemeral units to their base type and print that, and it may not work quite right for derived units.

nholthaus avatar Oct 06 '20 22:10 nholthaus

Right. I was just thinking of leaving that alone and using if constexpr branch for when the unit has an abbreviation.

JohelEGP avatar Oct 06 '20 22:10 JohelEGP