3#include "valkyrie/util/eigenunit/UnitMap.h"
13template <
typename... UnitTags>
14struct formatter<valor::EigenUnit::UnitVector<UnitTags...>> {
23 constexpr auto parse(format_parse_context& ctx) {
return spec.parse(ctx); }
28 template <
typename FormatContext>
29 auto format(
const Vec& vec, FormatContext& ctx)
const {
32 format_impl(vec, out, std::make_index_sequence<
sizeof...(UnitTags)>{});
41 template <
typename Out, std::size_t... Is>
42 void format_impl(
const Vec& vec, Out& out, std::index_sequence<Is...>)
const {
43 ((format_element<Is>(vec, out), (Is <
sizeof...(UnitTags) - 1 ? (*out++ =
',', *out++ =
' ', void()) : void())), ...);
49 template <std::
size_t I,
typename Out>
50 void format_element(
const Vec& vec, Out& out)
const {
51 using Tag = std::tuple_element_t<I, std::tuple<UnitTags...>>;
52 std::string s = spec.
format_value(vec.template Get<I>().value());
54 s += std::string(
" ") + units::abbreviation(units::unit_t<Tag>{});
55 out = std::ranges::copy(s, out).out;
63template <
typename... UnitTags>
64struct formatter<valor::EigenUnit::UnitMap<UnitTags...>> {
73 constexpr auto parse(format_parse_context& ctx) {
return spec.parse(ctx); }
78 template <
typename FormatContext>
79 auto format(
const Map& m, FormatContext& ctx)
const {
88template <
typename... UnitTags>
89struct formatter<valor::EigenUnit::ConstUnitMap<UnitTags...>> {
98 constexpr auto parse(format_parse_context& ctx) {
return spec.parse(ctx); }
103 template <
typename FormatContext>
A non-owning, read-only unit-safe view over a const double* buffer.
Definition UnitMap.h:202
UnitVector< UnitTags... > ToVector() const
Produce an owned UnitVector copy of the mapped data.
Definition UnitMap.h:250
A non-owning, unit-safe view over a raw double* buffer.
Definition UnitMap.h:18
UnitVector< UnitTags... > ToVector() const
Produce an owned UnitVector copy of the mapped data.
Definition UnitMap.h:107
A vector wrapper that enforces units for each element.
Definition UnitVector.h:22
Template specializations for std::tuple_size and std::tuple_element to support UnitVector.
Definition Formatters.h:8