diff --git a/example/unmanned_aerial_vehicle.cpp b/example/unmanned_aerial_vehicle.cpp index 634a0109..31f41e84 100644 --- a/example/unmanned_aerial_vehicle.cpp +++ b/example/unmanned_aerial_vehicle.cpp @@ -58,38 +58,28 @@ constexpr const char* to_text(earth_gravity_model m) } } -// TODO Why gcc does not deduce `M`? Is it a gcc bug? -// template -// std::basic_ostream& operator<<(std::basic_ostream& os, const hae_altitude& a) -// { -// return os << a.absolute() << " HAE(" << to_text(M) << ")"; -// } - -// template -// struct STD_FMT::formatter> : formatter::quantity_type> { -// template -// auto format(const hae_altitude& a, FormatContext& ctx) -// { -// formatter::quantity_type>::format(a.absolute(), ctx); -// return STD_FMT::format_to(ctx.out(), " HAE({})", to_text(M)); -// } -// }; - -template -std::basic_ostream& operator<<(std::basic_ostream& os, - const hae_altitude& a) +template +[[nodiscard]] consteval bool is_hae(height_above_ellipsoid_t) { - return os << a.absolute() << " HAE(" << to_text(earth_gravity_model::egm2008_1) << ")"; + return true; +} +[[nodiscard]] consteval bool is_hae(...) { return false; } + +template + requires(is_hae(QP::absolute_point_origin)) +std::basic_ostream& operator<<(std::basic_ostream& os, const QP& a) +{ + return os << a.absolute() << " HAE(" << to_text(a.absolute_point_origin.egm) << ")"; } -template<> -struct STD_FMT::formatter> : - formatter::quantity_type> { +template + requires(is_hae(QP::absolute_point_origin)) +struct STD_FMT::formatter : formatter { template - auto format(const hae_altitude& a, FormatContext& ctx) + auto format(const QP& a, FormatContext& ctx) { - formatter::quantity_type>::format(a.absolute(), ctx); - return STD_FMT::format_to(ctx.out(), " HAE({})", to_text(earth_gravity_model::egm2008_1)); + formatter::format(a.absolute(), ctx); + return STD_FMT::format_to(ctx.out(), " HAE({})", to_text(QP::absolute_point_origin.egm)); } };