55#include <fmt/format.h>
60#define GAUDI_PROPERTY_FORMATTING_IMPL( ns, assert_for_ranges ) \
61 template <typename T, typename V, typename H> \
62 struct ns::formatter<Gaudi::Property<T, V, H>> : ns::formatter<T> { \
65 constexpr auto parse( ns::format_parse_context& ctx ) { \
66 auto it = ctx.begin(), end = ctx.end(); \
67 if ( it != end && *it == '?' ) { \
70 if ( it != end && *it != '}' ) throw ns::format_error( "invalid format" ); \
73 return ns::formatter<T>::parse( ctx ); \
75 auto format( const Gaudi::Property<T, V, H>& p, ns::format_context& ctx ) const { \
77 if constexpr ( std::is_same_v<T, std::string> ) { \
78 std::stringstream s; \
79 s << std::quoted( p.value(), '\'' ); \
80 return ns::format_to( ctx.out(), " '{}':{}", p.name(), s.str() ); \
82 return ns::format_to( ctx.out(), " '{}':{}", p.name(), p.value() ); \
85 return ns::formatter<T>::format( static_cast<const T&>( p ), ctx ); \
92#ifndef __cpp_lib_format_ranges
93# define assert_for_ranges \
94 static_assert( !std::ranges::range<T> || std::is_same_v<T, std::string>, \
95 "Range-valued Property formatting is not supported with std::format in C++20" )
97# define assert_for_ranges static_assert( true )
102#undef assert_for_ranges
103#undef GAUDI_PROPERTY_FORMATTING_IMPL
#define GAUDI_PROPERTY_FORMATTING_IMPL(ns, assert_for_ranges)
Definitions to allow use of Gaudi::Property<T> with fmtlib.
#define assert_for_ranges