Skip to content

Commit

Permalink
Merge 626e860 into f62b580
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisCarouge committed May 11, 2024
2 parents f62b580 + 626e860 commit 8bd2163
Show file tree
Hide file tree
Showing 35 changed files with 1,140 additions and 582 deletions.
1 change: 1 addition & 0 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ target_sources(
"fcarouge/internal/function.hpp"
"fcarouge/internal/kalman.hpp"
"fcarouge/internal/kalman.tpp"
"fcarouge/internal/type.hpp"
"fcarouge/internal/utility.hpp"
"fcarouge/kalman.hpp"
"fcarouge/utility.hpp")
Expand Down
30 changes: 13 additions & 17 deletions include/fcarouge/internal/format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,49 +45,44 @@ For more information, please refer to <https://unlicense.org> */
#include <type_traits>

namespace fcarouge {
template <typename, typename, typename, typename, typename> class kalman;
template <typename> class kalman;
} // namespace fcarouge

template <typename State, typename Output, typename Input, typename UpdateTypes,
typename PredictionTypes, typename Char>
template <typename Filter, typename Char>
// It is allowed to add template specializations for any standard library class
// template to the namespace std only if the declaration depends on at least one
// program-defined type and the specialization satisfies all requirements for
// the original template, except where such specializations are prohibited.
// NOLINTNEXTLINE(cert-dcl58-cpp)
struct std::formatter<
fcarouge::kalman<State, Output, Input, UpdateTypes, PredictionTypes>,
Char> {
using kalman =
fcarouge::kalman<State, Output, Input, UpdateTypes, PredictionTypes>;

struct std::formatter<fcarouge::kalman<Filter>, Char> {
constexpr auto parse(std::basic_format_parse_context<Char> &parse_context) {
return parse_context.begin();
}

//! @todo P2585 may be useful in simplifying and standardizing the support.
template <typename OutputIt>
auto format(const kalman &filter,
auto format(const fcarouge::kalman<Filter> &filter,
std::basic_format_context<OutputIt, Char> &format_context) const
-> OutputIt {
format_context.advance_to(
format_to(format_context.out(), R"({{"f": {}, )", filter.f()));

if constexpr (fcarouge::internal::has_input_control_method<kalman>) {
if constexpr (fcarouge::has_input_control<Filter>) {
format_context.advance_to(
format_to(format_context.out(), R"("g": {}, )", filter.g()));
}

if constexpr (fcarouge::internal::has_output_model_method<kalman>) {
if constexpr (fcarouge::has_output_model<Filter>) {
format_context.advance_to(
format_to(format_context.out(), R"("h": {}, )", filter.h()));
}

format_context.advance_to(format_to(
format_context.out(), R"("k": {}, "p": {}, )", filter.k(), filter.p()));

{
constexpr auto end{fcarouge::internal::repack_s<PredictionTypes>};
if constexpr (fcarouge::internal::has_prediction_types<Filter>) {
constexpr auto end{
fcarouge::internal::repack_s<typename Filter::prediction_types>};
constexpr decltype(end) begin{0};
constexpr decltype(end) next{1};
fcarouge::internal::for_constexpr<begin, end, next>(
Expand All @@ -104,13 +99,14 @@ struct std::formatter<

//! @todo Generalize out internal method concept when MSVC has better
//! if-constexpr-requires support.
if constexpr (fcarouge::internal::has_input_method<kalman>) {
if constexpr (fcarouge::has_input<Filter>) {
format_context.advance_to(
format_to(format_context.out(), R"("u": {}, )", filter.u()));
}

{
constexpr auto end{fcarouge::internal::repack_s<UpdateTypes>};
if constexpr (fcarouge::internal::has_update_types<Filter>) {
constexpr auto end{
fcarouge::internal::repack_s<typename Filter::update_types>};
constexpr decltype(end) begin{0};
constexpr decltype(end) next{1};
fcarouge::internal::for_constexpr<begin, end, next>(
Expand Down
Loading

0 comments on commit 8bd2163

Please sign in to comment.