#include "tensorstore/util/unit.h"
tensorstore::Unit::Unit(std::string_view unit);
tensorstore::Unit::Unit(const charunit);
tensorstore::Unit::Unit(const std::stringunit);

Parses a combined multiplier and base unit from unit.

First, whitespace is stripped from the beginning and end of unit. Then, if there is a leading number (in JSON decimal number syntax), it is removed and used as the multiplier. The remainder (or the entire string in the case that there is no leading number) is used as the base_unit.

For example:

EXPECT_EQ(Unit(4, "nm"), Unit("4nm"));
EXPECT_EQ(Unit(4e-3, "nm"), Unit("4e-3nm"));
EXPECT_EQ(Unit(4e-3, "nm"), Unit("+4e-3nm"));
EXPECT_EQ(Unit(-4e-3, "nm"), Unit("-4e-3nm"));
EXPECT_EQ(Unit(4.5, "nm"), Unit("4.5nm"));
EXPECT_EQ(Unit(1, "nm"), Unit("nm"));
EXPECT_EQ(Unit(4, ""), Unit("4"));
EXPECT_EQ(Unit(1, ""), Unit(""));