feat(example): kalman filter examples enabled after text formatting refactoring
This commit is contained in:
1 parent
da0ab13b0d
commit
1cb86a2271
12 files changed
+429
-343
No files matched your search
@@ -30,6 +30,7 @@
|
||||
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic, cppcoreguidelines-pro-type-union-access)
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <mp-units/ext/algorithm.h>
|
||||
|
||||
@@ -45,6 +46,9 @@
|
||||
|
||||
namespace mp_units::detail {
|
||||
|
||||
// TODO the below should be exposed by the C++ Standard Library (used in our examples)
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
enum class fmt_align : std::int8_t { none, left, right, center, numeric };
|
||||
enum class fmt_arg_id_kind : std::int8_t {
|
||||
none,
|
||||
@@ -109,6 +113,8 @@ public:
|
||||
[[nodiscard]] constexpr const Char& operator[](size_t index) const { return data_[index]; }
|
||||
};
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
template<typename T>
|
||||
inline constexpr bool is_integer =
|
||||
std::is_integral_v<T> && !std::is_same_v<T, bool> && !std::is_same_v<T, char> && !std::is_same_v<T, wchar_t>;
|
||||
@@ -135,20 +141,6 @@ template<typename Int>
|
||||
return static_cast<std::make_unsigned_t<Int>>(value);
|
||||
}
|
||||
|
||||
struct width_checker {
|
||||
template<typename T>
|
||||
[[nodiscard]] constexpr unsigned long long operator()(T value) const
|
||||
{
|
||||
if constexpr (is_integer<T>) {
|
||||
if constexpr (std::numeric_limits<T>::is_signed)
|
||||
if (value < 0) MP_UNITS_THROW(MP_UNITS_STD_FMT::format_error("negative width"));
|
||||
return static_cast<unsigned long long>(value);
|
||||
}
|
||||
MP_UNITS_THROW(MP_UNITS_STD_FMT::format_error("width is not integer"));
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Handler, typename FormatArg>
|
||||
[[nodiscard]] constexpr int get_dynamic_spec(FormatArg arg)
|
||||
{
|
||||
@@ -167,6 +159,9 @@ template<typename Context, typename ID>
|
||||
return arg;
|
||||
}
|
||||
|
||||
// TODO the below should be exposed by the C++ Standard Library (used in our examples)
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
template<class Handler, typename Context>
|
||||
constexpr void handle_dynamic_spec(int& value, fmt_arg_ref<typename Context::char_type> ref, Context& ctx)
|
||||
{
|
||||
@@ -184,6 +179,22 @@ constexpr void handle_dynamic_spec(int& value, fmt_arg_ref<typename Context::cha
|
||||
}
|
||||
}
|
||||
|
||||
struct width_checker {
|
||||
template<typename T>
|
||||
[[nodiscard]] constexpr unsigned long long operator()(T value) const
|
||||
{
|
||||
if constexpr (is_integer<T>) {
|
||||
if constexpr (std::numeric_limits<T>::is_signed)
|
||||
if (value < 0) MP_UNITS_THROW(MP_UNITS_STD_FMT::format_error("negative width"));
|
||||
return static_cast<unsigned long long>(value);
|
||||
}
|
||||
MP_UNITS_THROW(MP_UNITS_STD_FMT::format_error("width is not integer"));
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
// Parses the range [begin, end) as an unsigned integer. This function assumes
|
||||
// that the range is non-empty and the first character is a digit.
|
||||
template<typename Char>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/fmt.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <mp-units/ext/algorithm.h>
|
||||
#include <mp-units/framework/customization_points.h>
|
||||
@@ -33,14 +34,6 @@
|
||||
|
||||
namespace mp_units::detail {
|
||||
|
||||
template<typename Char>
|
||||
struct fill_align_width_format_specs {
|
||||
fill_t<Char> fill;
|
||||
fmt_align align : 4 = fmt_align::none;
|
||||
int width = 0;
|
||||
fmt_arg_ref<Char> width_ref;
|
||||
};
|
||||
|
||||
template<typename Char>
|
||||
[[nodiscard]] constexpr const Char* at_most_one_of(const Char* begin, const Char* end, std::string_view modifiers)
|
||||
{
|
||||
@@ -51,6 +44,17 @@ template<typename Char>
|
||||
return it;
|
||||
}
|
||||
|
||||
// TODO the below should be exposed by the C++ Standard Library (used in our examples)
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
template<typename Char>
|
||||
struct fill_align_width_format_specs {
|
||||
fill_t<Char> fill;
|
||||
fmt_align align : 4 = fmt_align::none;
|
||||
int width = 0;
|
||||
fmt_arg_ref<Char> width_ref;
|
||||
};
|
||||
|
||||
template<typename Char, typename Specs>
|
||||
[[nodiscard]] constexpr const Char* parse_fill_align_width(MP_UNITS_STD_FMT::basic_format_parse_context<Char>& ctx,
|
||||
const Char* begin, const Char* end, Specs& specs,
|
||||
@@ -89,6 +93,8 @@ OutputIt format_global_buffer(OutputIt out, const fill_align_width_format_specs<
|
||||
return MP_UNITS_STD_FMT::format_to(out, "}}");
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
} // namespace mp_units::detail
|
||||
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user