File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828#include < cstddef>
2929
3030#include " StaConfig.hh"
31+ #include " Format.hh"
3132#include " MinMax.hh"
3233
3334namespace sta {
@@ -356,4 +357,32 @@ Delay
356357delayRemove (const Delay &delay1,
357358 const Delay &delay2);
358359
359- } // namespace
360+ } // namespace sta
361+
362+
363+ // Default formatter for Delay. delayAsString is preferred.
364+ #if defined(__cpp_lib_format) && __cpp_lib_format >= 201907L
365+ #include < format>
366+
367+ namespace std {
368+ template <>
369+ struct formatter <sta::Delay> : formatter<std::string_view> {
370+ auto format (const sta::Delay& delay, format_context& ctx) const {
371+ std::string s = std::format (" {:.3e}" , delay.mean ());
372+ return formatter<std::string_view>::format (s, ctx);
373+ }
374+ };
375+ } // namespace std
376+ #else
377+ #include < fmt/core.h>
378+
379+ namespace fmt {
380+ template <>
381+ struct formatter <sta::Delay> : formatter<std::string_view> {
382+ auto format (const sta::Delay& delay, format_context& ctx) const {
383+ return formatter<std::string_view>::format (
384+ fmt::format (" {:.3e}" , delay.mean ()), ctx);
385+ }
386+ };
387+ } // namespace fmt
388+ #endif
You can’t perform that action at this time.
0 commit comments