23 #ifndef COM_DAFER45_TBTK_QUANTITY_QUANTITY
24 #define COM_DAFER45_TBTK_QUANTITY_QUANTITY
167 template<
typename Units,
typename Exponents>
171 using Exponent = Exponents;
193 static Unit
getUnit(
const std::string &unit);
204 static class ConversionTable{
206 std::map<Unit, std::string> unitToString;
207 std::map<std::string, Unit> stringToUnit;
208 std::map<Unit, double> conversionFactors;
213 std::pair<std::string, double>
216 for(
auto entry : conversionTable){
217 unitToString[entry.first] = entry.second.first;
218 stringToUnit[entry.second.first] = entry.first;
219 conversionFactors[entry.first]
220 = entry.second.second;
226 template<
typename Units,
typename Exponents>
229 return conversionTable.unitToString.at(unit);
231 catch(
const std::out_of_range &e){
233 "Quantity::getUnitString()",
234 "Unknown unit '" <<
static_cast<int>(unit) <<
"'.",
241 template<
typename Units,
typename Exponents>
243 const std::string &unit
246 return conversionTable.stringToUnit.at(unit);
248 catch(
const std::out_of_range &e){
250 "Quantity::getUnit()",
251 "Unknown unit '" << unit <<
"'.",
257 template<
typename Units,
typename Exponents>
260 return conversionTable.conversionFactors.at(unit);
262 catch(
const std::out_of_range &e){
264 "Quantity::getConversionFactor()",
265 "Unknown unit '" <<
static_cast<int>(unit) <<
"'.",