onboardsdk
Loading...
Searching...
No Matches
eigen_formatters.hpp
1#pragma once
2
3#include "Eigen/Geometry"
4
5#if FMT_VERSION >= 90000
6
7#include <fmt/ostream.h>
8
15template <typename Scalar_, int Rows_, int Cols_, int Options_, int MaxRows_,
16 int MaxCols_>
17struct fmt::formatter<
18 Eigen::Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>>
19 : ostream_formatter {};
20
27template <typename T>
28struct fmt::formatter<Eigen::Transpose<T>> : ostream_formatter {};
29#endif
30
37template <>
38struct fmt::formatter<Eigen::Vector3d> {
45 template <typename ParseContext>
46 // NOLINTNEXTLINE(runtime/references)
47 constexpr auto parse(ParseContext& ctx) {
48 return ctx.begin();
49 }
50
58 template <typename FormatContext>
59 // NOLINTNEXTLINE(runtime/references)
60 auto format(Eigen::Vector3d const& v, FormatContext& ctx) const {
61 return fmt::format_to(ctx.out(), "x: {} y: {} z: {}", v.x(), v.y(), v.z());
62 }
63};
constexpr auto parse(ParseContext &ctx)
Parses the format string.
Definition eigen_formatters.hpp:47
auto format(Eigen::Vector3d const &v, FormatContext &ctx) const
Formats the Eigen 3D vector.
Definition eigen_formatters.hpp:60