feat(example): text output added to validated_type and ranged_representation

This commit is contained in:
Mateusz Pusz
2023-09-04 11:15:33 +02:00
parent b84c74b330
commit b3fb025053
2 changed files with 31 additions and 0 deletions

View File

@@ -24,6 +24,7 @@
#include "validated_type.h"
#include <mp-units/bits/external/hacks.h>
#include <mp-units/bits/fmt.h>
#include <mp-units/customization_points.h>
#include <algorithm>
#include <concepts>
@@ -53,3 +54,12 @@ public:
template<typename T, auto Min, auto Max>
inline constexpr bool mp_units::is_scalar<ranged_representation<T, Min, Max>> = mp_units::is_scalar<T>;
template<typename T, auto Min, auto Max>
struct MP_UNITS_STD_FMT::formatter<ranged_representation<T, Min, Max>> : formatter<T> {
template<typename FormatContext>
auto format(const ranged_representation<T, Min, Max>& v, FormatContext& ctx)
{
return formatter<T>::format(v.value(), ctx);
}
};