Skip to content

Commit 465b65e

Browse files
committed
fix: replace uses of deprecated has_formatter
use is_formattable instead. has_formatter was never a good API, since it only asked if the type has a `formatter` specialization, but a type can also be formattable if it provides an implicit conversion to a type which does. The newer API takes care of the that problem. as a drive-by, provides format_as free function for dom::Value instead of a fmt::formatter specialization.
1 parent 1a5b15a commit 465b65e

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

include/mrdocs/Dom/Value.hpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ class MRDOCS_DECL
527527
toString(Value const& value);
528528
};
529529

530+
inline auto format_as(Value value) { return toString(value); }
531+
530532
//------------------------------------------------
531533

532534
namespace JSON
@@ -847,19 +849,4 @@ safeString(SV const& str) {
847849
#include <mrdocs/Dom/Function.ipp>
848850
#include <mrdocs/Dom/Object.ipp>
849851

850-
//------------------------------------------------
851-
852-
template<>
853-
struct fmt::formatter<clang::mrdocs::dom::Value>
854-
: public fmt::formatter<std::string>
855-
{
856-
auto format(
857-
clang::mrdocs::dom::Value const& value,
858-
fmt::format_context& ctx) const
859-
{
860-
return fmt::formatter<std::string>::format(
861-
toString(value), ctx);
862-
}
863-
};
864-
865852
#endif

include/mrdocs/Support/Handlebars.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class MRDOCS_DECL OutputRef
218218
@return A reference to this object
219219
*/
220220
template <class T>
221-
requires fmt::has_formatter<T, fmt::format_context>::value
221+
requires fmt::formattable<T>
222222
friend
223223
OutputRef&
224224
operator<<( OutputRef& os, T v )

src/test_suite/detail/decomposer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace test_suite::detail
5353
out += '\"';
5454
}
5555
#ifdef MRDOCS_TEST_HAS_FMT
56-
if constexpr (fmt::has_formatter<T, fmt::format_context>::value) {
56+
if constexpr (fmt::is_formattable<T>::value) {
5757
out += fmt::format("{}", value);
5858
} else
5959
#endif

0 commit comments

Comments
 (0)