Opened 7 years ago

Last modified 7 years ago

#11336 new Bugs

units: base_unit_info name and symbol unavailable for absolute units

Reported by: Roger Leigh <rleigh@…> Owned by: Matthias Schabel
Milestone: To Be Determined Component: units
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

absolute<> works for making temperatures absolute. However, it does not define a specialisation of the base_unit_info, so name_string and symbol_string are unavailable and some methods fails as a result.

Please consider making absolute<> provide a base_unit_info specialisation which delegates to the wrapped unit type's base_unit_info, but adds an "absolute " prefix to both and can replace the ostream operator which works partially for the symbol case, but not the unit name which is completely absent. This will make absolute<> behave the same as a normal unwrapped unit.

Attachments (1)

test_abs_units.cpp (1.7 KB ) - added by Roger Leigh <rleigh@…> 7 years ago.
Example of failure to get unit name/symbol from absolute units

Download all attachments as: .zip

Change History (5)

comment:1 by Steven Watanabe, 7 years ago

absolute is not a base_unit, so this is not the correct fix. Can you provide a small test case the demonstrates the problem? The test for output seems to be passing for absolute with both symbols and unit names.

by Roger Leigh <rleigh@…>, 7 years ago

Attachment: test_abs_units.cpp added

Example of failure to get unit name/symbol from absolute units

comment:2 by Roger Leigh <rleigh@…>, 7 years ago

Hi Steven,

I have attached an example file to demonstrate the problem. Uncomment the comments to get my workaround for getting it to compile and function, though I don't really like this.

I'm not using base_unit_info directly; I'm using name_string and symbol_string from io.hpp, and these are failing with absolute units. I assumed these should work with all unit types for output, rather than being limited to base units.

Kind regards, Roger

comment:3 by Steven Watanabe, 7 years ago

So, the problem is that there aren't overloads of name_string/symbol_string for absolute. That's easy to fix.

comment:4 by Roger Leigh <rleigh@…>, 7 years ago

That could certainly be the case. Being so heavily templated, I wasn't entirely certain exactly where the boundary between internal implementation and public interface was. If it's as simple as overloading those methods, that's great.

Would that also imply the absolute ostream operator<< could be removed since they would do its job?

Note: See TracTickets for help on using tickets.