35 auto format(
const Unit& obj, FmtContext& ctx)
const {
36 using Units =
typename Unit::unit_type;
39 typename units::traits::unit_traits<Units>::base_unit_type>;
45 if constexpr (units::traits::unit_traits<
46 Units>::base_unit_type::meter_ratio::num != 0) {
47 out = fmt::format_to(out,
" m");
49 if constexpr (units::traits::unit_traits<
50 Units>::base_unit_type::meter_ratio::num != 0 &&
51 units::traits::unit_traits<
52 Units>::base_unit_type::meter_ratio::num != 1) {
55 units::traits::unit_traits<Units>::base_unit_type::meter_ratio::num);
57 if constexpr (units::traits::unit_traits<
58 Units>::base_unit_type::meter_ratio::den != 1) {
61 units::traits::unit_traits<Units>::base_unit_type::meter_ratio::den);
64 if constexpr (units::traits::unit_traits<
65 Units>::base_unit_type::kilogram_ratio::num != 0) {
66 out = fmt::format_to(out,
" kg");
68 if constexpr (units::traits::unit_traits<
69 Units>::base_unit_type::kilogram_ratio::num != 0 &&
70 units::traits::unit_traits<
71 Units>::base_unit_type::kilogram_ratio::num != 1) {
72 out = fmt::format_to(out,
"^{}",
73 units::traits::unit_traits<
74 Units>::base_unit_type::kilogram_ratio::num);
76 if constexpr (units::traits::unit_traits<
77 Units>::base_unit_type::kilogram_ratio::den != 1) {
78 out = fmt::format_to(out,
"/{}",
79 units::traits::unit_traits<
80 Units>::base_unit_type::kilogram_ratio::den);
83 if constexpr (units::traits::unit_traits<
84 Units>::base_unit_type::second_ratio::num != 0) {
85 out = fmt::format_to(out,
" s");
87 if constexpr (units::traits::unit_traits<
88 Units>::base_unit_type::second_ratio::num != 0 &&
89 units::traits::unit_traits<
90 Units>::base_unit_type::second_ratio::num != 1) {
93 units::traits::unit_traits<Units>::base_unit_type::second_ratio::num);
95 if constexpr (units::traits::unit_traits<
96 Units>::base_unit_type::second_ratio::den != 1) {
99 units::traits::unit_traits<Units>::base_unit_type::second_ratio::den);
102 if constexpr (units::traits::unit_traits<
103 Units>::base_unit_type::ampere_ratio::num != 0) {
104 out = fmt::format_to(out,
" A");
106 if constexpr (units::traits::unit_traits<
107 Units>::base_unit_type::ampere_ratio::num != 0 &&
108 units::traits::unit_traits<
109 Units>::base_unit_type::ampere_ratio::num != 1) {
110 out = fmt::format_to(
112 units::traits::unit_traits<Units>::base_unit_type::ampere_ratio::num);
114 if constexpr (units::traits::unit_traits<
115 Units>::base_unit_type::ampere_ratio::den != 1) {
116 out = fmt::format_to(
118 units::traits::unit_traits<Units>::base_unit_type::ampere_ratio::den);
121 if constexpr (units::traits::unit_traits<
122 Units>::base_unit_type::kelvin_ratio::num != 0) {
123 out = fmt::format_to(out,
" K");
125 if constexpr (units::traits::unit_traits<
126 Units>::base_unit_type::kelvin_ratio::num != 0 &&
127 units::traits::unit_traits<
128 Units>::base_unit_type::kelvin_ratio::num != 1) {
129 out = fmt::format_to(
131 units::traits::unit_traits<Units>::base_unit_type::kelvin_ratio::num);
133 if constexpr (units::traits::unit_traits<
134 Units>::base_unit_type::kelvin_ratio::den != 1) {
135 out = fmt::format_to(
137 units::traits::unit_traits<Units>::base_unit_type::kelvin_ratio::den);
140 if constexpr (units::traits::unit_traits<
141 Units>::base_unit_type::mole_ratio::num != 0) {
142 out = fmt::format_to(out,
" mol");
144 if constexpr (units::traits::unit_traits<
145 Units>::base_unit_type::mole_ratio::num != 0 &&
146 units::traits::unit_traits<
147 Units>::base_unit_type::mole_ratio::num != 1) {
148 out = fmt::format_to(
150 units::traits::unit_traits<Units>::base_unit_type::mole_ratio::num);
152 if constexpr (units::traits::unit_traits<
153 Units>::base_unit_type::mole_ratio::den != 1) {
154 out = fmt::format_to(
156 units::traits::unit_traits<Units>::base_unit_type::mole_ratio::den);
159 if constexpr (units::traits::unit_traits<
160 Units>::base_unit_type::candela_ratio::num != 0) {
161 out = fmt::format_to(out,
" cd");
163 if constexpr (units::traits::unit_traits<
164 Units>::base_unit_type::candela_ratio::num != 0 &&
165 units::traits::unit_traits<
166 Units>::base_unit_type::candela_ratio::num != 1) {
167 out = fmt::format_to(out,
"^{}",
168 units::traits::unit_traits<
169 Units>::base_unit_type::candela_ratio::num);
171 if constexpr (units::traits::unit_traits<
172 Units>::base_unit_type::candela_ratio::den != 1) {
173 out = fmt::format_to(out,
"/{}",
174 units::traits::unit_traits<
175 Units>::base_unit_type::candela_ratio::den);
178 if constexpr (units::traits::unit_traits<
179 Units>::base_unit_type::radian_ratio::num != 0) {
180 out = fmt::format_to(out,
" rad");
182 if constexpr (units::traits::unit_traits<
183 Units>::base_unit_type::radian_ratio::num != 0 &&
184 units::traits::unit_traits<
185 Units>::base_unit_type::radian_ratio::num != 1) {
186 out = fmt::format_to(
188 units::traits::unit_traits<Units>::base_unit_type::radian_ratio::num);
190 if constexpr (units::traits::unit_traits<
191 Units>::base_unit_type::radian_ratio::den != 1) {
192 out = fmt::format_to(
194 units::traits::unit_traits<Units>::base_unit_type::radian_ratio::den);
197 if constexpr (units::traits::unit_traits<
198 Units>::base_unit_type::byte_ratio::num != 0) {
199 out = fmt::format_to(out,
" b");
201 if constexpr (units::traits::unit_traits<
202 Units>::base_unit_type::byte_ratio::num != 0 &&
203 units::traits::unit_traits<
204 Units>::base_unit_type::byte_ratio::num != 1) {
205 out = fmt::format_to(
207 units::traits::unit_traits<Units>::base_unit_type::byte_ratio::num);
209 if constexpr (units::traits::unit_traits<
210 Units>::base_unit_type::byte_ratio::den != 1) {
211 out = fmt::format_to(
213 units::traits::unit_traits<Units>::base_unit_type::byte_ratio::den);