20template <
typename Unit,
typename CharT>
21struct fmt::formatter<Unit, CharT,
24 return m_underlying.parse(ctx);
34 using Units =
typename Unit::unit_type;
37 typename units::traits::unit_traits<Units>::base_unit_type>;
41 out = m_underlying.format(units::convert<Units, BaseUnits>(obj()), ctx);
43 if constexpr (units::traits::unit_traits<
44 Units>::base_unit_type::meter_ratio::num != 0) {
47 if constexpr (units::traits::unit_traits<
48 Units>::base_unit_type::meter_ratio::num != 0 &&
49 units::traits::unit_traits<
50 Units>::base_unit_type::meter_ratio::num != 1) {
53 units::traits::unit_traits<Units>::base_unit_type::meter_ratio::num);
55 if constexpr (units::traits::unit_traits<
56 Units>::base_unit_type::meter_ratio::den != 1) {
59 units::traits::unit_traits<Units>::base_unit_type::meter_ratio::den);
62 if constexpr (units::traits::unit_traits<
63 Units>::base_unit_type::kilogram_ratio::num != 0) {
66 if constexpr (units::traits::unit_traits<
67 Units>::base_unit_type::kilogram_ratio::num != 0 &&
68 units::traits::unit_traits<
69 Units>::base_unit_type::kilogram_ratio::num != 1) {
71 units::traits::unit_traits<
72 Units>::base_unit_type::kilogram_ratio::num);
74 if constexpr (units::traits::unit_traits<
75 Units>::base_unit_type::kilogram_ratio::den != 1) {
77 units::traits::unit_traits<
78 Units>::base_unit_type::kilogram_ratio::den);
81 if constexpr (units::traits::unit_traits<
82 Units>::base_unit_type::second_ratio::num != 0) {
85 if constexpr (units::traits::unit_traits<
86 Units>::base_unit_type::second_ratio::num != 0 &&
87 units::traits::unit_traits<
88 Units>::base_unit_type::second_ratio::num != 1) {
91 units::traits::unit_traits<Units>::base_unit_type::second_ratio::num);
93 if constexpr (units::traits::unit_traits<
94 Units>::base_unit_type::second_ratio::den != 1) {
97 units::traits::unit_traits<Units>::base_unit_type::second_ratio::den);
100 if constexpr (units::traits::unit_traits<
101 Units>::base_unit_type::ampere_ratio::num != 0) {
104 if constexpr (units::traits::unit_traits<
105 Units>::base_unit_type::ampere_ratio::num != 0 &&
106 units::traits::unit_traits<
107 Units>::base_unit_type::ampere_ratio::num != 1) {
110 units::traits::unit_traits<Units>::base_unit_type::ampere_ratio::num);
112 if constexpr (units::traits::unit_traits<
113 Units>::base_unit_type::ampere_ratio::den != 1) {
116 units::traits::unit_traits<Units>::base_unit_type::ampere_ratio::den);
119 if constexpr (units::traits::unit_traits<
120 Units>::base_unit_type::kelvin_ratio::num != 0) {
123 if constexpr (units::traits::unit_traits<
124 Units>::base_unit_type::kelvin_ratio::num != 0 &&
125 units::traits::unit_traits<
126 Units>::base_unit_type::kelvin_ratio::num != 1) {
129 units::traits::unit_traits<Units>::base_unit_type::kelvin_ratio::num);
131 if constexpr (units::traits::unit_traits<
132 Units>::base_unit_type::kelvin_ratio::den != 1) {
135 units::traits::unit_traits<Units>::base_unit_type::kelvin_ratio::den);
138 if constexpr (units::traits::unit_traits<
139 Units>::base_unit_type::mole_ratio::num != 0) {
142 if constexpr (units::traits::unit_traits<
143 Units>::base_unit_type::mole_ratio::num != 0 &&
144 units::traits::unit_traits<
145 Units>::base_unit_type::mole_ratio::num != 1) {
148 units::traits::unit_traits<Units>::base_unit_type::mole_ratio::num);
150 if constexpr (units::traits::unit_traits<
151 Units>::base_unit_type::mole_ratio::den != 1) {
154 units::traits::unit_traits<Units>::base_unit_type::mole_ratio::den);
157 if constexpr (units::traits::unit_traits<
158 Units>::base_unit_type::candela_ratio::num != 0) {
161 if constexpr (units::traits::unit_traits<
162 Units>::base_unit_type::candela_ratio::num != 0 &&
163 units::traits::unit_traits<
164 Units>::base_unit_type::candela_ratio::num != 1) {
166 units::traits::unit_traits<
167 Units>::base_unit_type::candela_ratio::num);
169 if constexpr (units::traits::unit_traits<
170 Units>::base_unit_type::candela_ratio::den != 1) {
172 units::traits::unit_traits<
173 Units>::base_unit_type::candela_ratio::den);
176 if constexpr (units::traits::unit_traits<
177 Units>::base_unit_type::radian_ratio::num != 0) {
180 if constexpr (units::traits::unit_traits<
181 Units>::base_unit_type::radian_ratio::num != 0 &&
182 units::traits::unit_traits<
183 Units>::base_unit_type::radian_ratio::num != 1) {
186 units::traits::unit_traits<Units>::base_unit_type::radian_ratio::num);
188 if constexpr (units::traits::unit_traits<
189 Units>::base_unit_type::radian_ratio::den != 1) {
192 units::traits::unit_traits<Units>::base_unit_type::radian_ratio::den);
195 if constexpr (units::traits::unit_traits<
196 Units>::base_unit_type::byte_ratio::num != 0) {
199 if constexpr (units::traits::unit_traits<
200 Units>::base_unit_type::byte_ratio::num != 0 &&
201 units::traits::unit_traits<
202 Units>::base_unit_type::byte_ratio::num != 1) {
205 units::traits::unit_traits<Units>::base_unit_type::byte_ratio::num);
207 if constexpr (units::traits::unit_traits<
208 Units>::base_unit_type::byte_ratio::den != 1) {
211 units::traits::unit_traits<Units>::base_unit_type::byte_ratio::den);
218 fmt::formatter<typename Unit::underlying_type, CharT> m_underlying;
typename std::enable_if< B, T >::type enable_if_t
Definition: core.h:256
buffer_context< char > format_context
Definition: core.h:1759
basic_format_parse_context< char > format_parse_context
Definition: core.h:722
Type representing an arbitrary unit.
Definition: base.h:884
auto format_to(OutputIt out, const S &fmt, T &&... args) -> OutputIt
Definition: xchar.h:156