/** @file basis_unit.hpp **/ #include "dim_util.hpp" #include "ratio_util.hpp" namespace xo { namespace unit { /** @class basis_unit * * @brief A dimensionless multiple with natively-specified (i.e. at compile-time) dimension **/ template , typename InnerScale = std::ratio<1>> struct basis_unit { static_assert(ratio_concept); static constexpr dim c_native_dim = BasisDim; static constexpr basis_unit c_native_unit = NativeUnitId; using scalefactor_type = InnerScale; }; /** Using struct wrapper so we can partially specialize * Specializations in [dimension.hpp], see also **/ template struct native_unit_abbrev_helper; template <> struct native_unit_abbrev_helper { static constexpr auto value = stringliteral("g"); }; template <> struct native_unit_abbrev_helper { static constexpr auto value = stringliteral("m"); }; template <> struct native_unit_abbrev_helper { static constexpr auto value = stringliteral("s"); }; template<> struct native_unit_abbrev_helper { static constexpr auto value = stringliteral("ccy"); }; template<> struct native_unit_abbrev_helper { static constexpr auto value = stringliteral("px"); }; template constexpr auto native_unit_abbrev_v = native_unit_abbrev_helper::value; namespace units { // ----- scaled_native_unit_abbrev_helper ----- /* Require: InnerScale is ratio type; InnerScale >= 1 */ template struct scaled_native_unit_abbrev; template struct scaled_native_unit_abbrev> { static constexpr auto value = native_unit_abbrev_v; }; template struct scaled_native_unit_abbrev { /* e.g. unit of '10000 grams' will have abbrev '1000g' in absence * of a specialization for scaled_native_unit_abbrev */ static constexpr auto value = stringliteral_concat(stringliteral_from_ratio().value_, native_unit_abbrev_helper::value.value_); }; template constexpr auto scaled_native_unit_abbrev_v = scaled_native_unit_abbrev::value; } } /*namespace unit*/ } /*namespace xo*/ /** end basis_unit.hpp **/