diff --git a/cmake_config.h.in b/cmake_config.h.in index 64db4ade9e..fdf9aa4e34 100644 --- a/cmake_config.h.in +++ b/cmake_config.h.in @@ -98,12 +98,14 @@ #define INCLUDE_FMT_RANGES #define INCLUDE_FMT_OSTREAM - #define VT_FMT_NAMESPACE namespace fmt + #define VT_FMT_NAMESPACE_BEGIN namespace fmt { + #define VT_FMT_NAMESPACE_END } #else #define INCLUDE_FMT_CORE #define INCLUDE_FMT_FORMAT #define INCLUDE_FMT_RANGES #define INCLUDE_FMT_OSTREAM - #define VT_FMT_NAMESPACE namespace fmt::vt + #define VT_FMT_NAMESPACE_BEGIN namespace fmt { inline namespace vt { + #define VT_FMT_NAMESPACE_END } } #endif diff --git a/src/vt/rdma/rdma_common.h b/src/vt/rdma/rdma_common.h index 47cacb70cb..3660aa7d7f 100644 --- a/src/vt/rdma/rdma_common.h +++ b/src/vt/rdma/rdma_common.h @@ -117,7 +117,7 @@ static constexpr ByteType rdma_default_byte_size = sizeof(char); }} //end namespace vt::rdma -VT_FMT_NAMESPACE { +VT_FMT_NAMESPACE_BEGIN template <> struct formatter<::vt::rdma::Type> : formatter { template @@ -136,11 +136,13 @@ VT_FMT_NAMESPACE { case ::vt::rdma::Type::Uninitialized: name = "Uninitialized"; break; + default: + name = fmt::format("{}", static_cast>(t)); } return formatter::format(name, ctx); } }; -} // VT_FMT_NAMESPACE +VT_FMT_NAMESPACE_END #define PRINT_CHANNEL_TYPE(rdma_op_type) ( \ rdma_op_type == vt::rdma::Type::Get ? "rdma::Get" : ( \ diff --git a/src/vt/termination/interval/interval.h b/src/vt/termination/interval/interval.h index 99da07d776..7d9a81c5e8 100644 --- a/src/vt/termination/interval/interval.h +++ b/src/vt/termination/interval/interval.h @@ -237,7 +237,7 @@ struct Interval; }}} -VT_FMT_NAMESPACE { +VT_FMT_NAMESPACE_BEGIN template struct formatter<::vt::term::interval::Interval> : formatter { @@ -249,6 +249,6 @@ VT_FMT_NAMESPACE { ctx.out(), "Interval[{}, {}]", interval.lower(), interval.upper()); } }; -} // VT_FMT_NAMESPACE +VT_FMT_NAMESPACE_END #endif /*INCLUDED_VT_TERMINATION_INTERVAL_INTERVAL_H*/ diff --git a/src/vt/timing/timing.h b/src/vt/timing/timing.h index 7e7cc02a83..560efbd0b1 100644 --- a/src/vt/timing/timing.h +++ b/src/vt/timing/timing.h @@ -63,7 +63,7 @@ TimeType getCurrentTime(); }} /* end namespace vt::timing */ -VT_FMT_NAMESPACE { +VT_FMT_NAMESPACE_BEGIN template <> struct formatter<::vt::TimeTypeWrapper> { template @@ -79,6 +79,6 @@ VT_FMT_NAMESPACE { } }; -} // VT_FMT_NAMESPACE +VT_FMT_NAMESPACE_END #endif /*INCLUDED_VT_TIMING_TIMING_H*/ diff --git a/src/vt/topos/index/dense/dense_array.h b/src/vt/topos/index/dense/dense_array.h index 9a57c856e0..61e3b7fddf 100644 --- a/src/vt/topos/index/dense/dense_array.h +++ b/src/vt/topos/index/dense/dense_array.h @@ -159,7 +159,7 @@ static_assert( }} // end namespace vt::index -VT_FMT_NAMESPACE { +VT_FMT_NAMESPACE_BEGIN template struct formatter<::vt::index::DenseIndexArray> : formatter> { @@ -170,7 +170,7 @@ VT_FMT_NAMESPACE { return formatter>::format(wrapper.dims, ctx); } }; -} // VT_FMT_NAMESPACE +VT_FMT_NAMESPACE_END #include "vt/topos/index/dense/dense_array.impl.h" diff --git a/src/vt/vrt/collection/balance/greedylb/greedylb.h b/src/vt/vrt/collection/balance/greedylb/greedylb.h index 27177a6558..0ead714ee0 100644 --- a/src/vt/vrt/collection/balance/greedylb/greedylb.h +++ b/src/vt/vrt/collection/balance/greedylb/greedylb.h @@ -126,7 +126,7 @@ struct GreedyLB : LoadSamplerBaseLB { }}}} /* end namespace vt::vrt::collection::lb */ -VT_FMT_NAMESPACE { +VT_FMT_NAMESPACE_BEGIN template <> struct formatter<::vt::vrt::collection::lb::DataDistStrategy> : formatter { @@ -149,6 +149,6 @@ VT_FMT_NAMESPACE { } }; -} // VT_FMT_NAMESPACE +VT_FMT_NAMESPACE_END #endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_GREEDYLB_GREEDYLB_H*/ diff --git a/src/vt/vrt/collection/balance/lb_args_enum_converter.h b/src/vt/vrt/collection/balance/lb_args_enum_converter.h index 050adfeb86..fa2dce3ccb 100644 --- a/src/vt/vrt/collection/balance/lb_args_enum_converter.h +++ b/src/vt/vrt/collection/balance/lb_args_enum_converter.h @@ -100,7 +100,7 @@ struct LBArgsEnumConverter { auto err = fmt::format( "LBArgsEnumConverter: enum '{}' value '{}' corresponding to LB " "argument '{}' does not have a string associated with it", - enum_type_, e, par_name_ + enum_type_, static_cast>(e), par_name_ ); vtAbort(err); } diff --git a/src/vt/vrt/collection/balance/temperedlb/criterion.h b/src/vt/vrt/collection/balance/temperedlb/criterion.h index 5f1e278771..1f7d7784b4 100644 --- a/src/vt/vrt/collection/balance/temperedlb/criterion.h +++ b/src/vt/vrt/collection/balance/temperedlb/criterion.h @@ -93,7 +93,7 @@ struct Criterion { }}}} /* end namespace vt::vrt::collection::lb */ -VT_FMT_NAMESPACE { +VT_FMT_NAMESPACE_BEGIN template <> struct formatter<::vt::vrt::collection::lb::CriterionEnum> : formatter { @@ -113,6 +113,6 @@ VT_FMT_NAMESPACE { } }; -} // VT_FMT_NAMESPACE +VT_FMT_NAMESPACE_END #endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_TEMPEREDLB_CRITERION_H*/ diff --git a/src/vt/vrt/collection/balance/temperedlb/tempered_enums.h b/src/vt/vrt/collection/balance/temperedlb/tempered_enums.h index 8c2ca050c7..b56414a333 100644 --- a/src/vt/vrt/collection/balance/temperedlb/tempered_enums.h +++ b/src/vt/vrt/collection/balance/temperedlb/tempered_enums.h @@ -167,103 +167,4 @@ enum struct KnowledgeEnum : uint8_t { }}}} /* end namespace vt::vrt::collection::lb */ -VT_FMT_NAMESPACE { - // Specialize fmt::formatter for ObjectOrderEnum - template <> - struct formatter<::vt::vrt::collection::lb::ObjectOrderEnum> - : formatter { - template - auto - format(::vt::vrt::collection::lb::ObjectOrderEnum c, FormatContext& ctx) { - std::string_view name = "Unknown"; - switch (c) { - case ::vt::vrt::collection::lb::ObjectOrderEnum::Arbitrary: - name = "Arbitrary"; - break; - case ::vt::vrt::collection::lb::ObjectOrderEnum::ElmID: - name = "ElmID"; - break; - case ::vt::vrt::collection::lb::ObjectOrderEnum::FewestMigrations: - name = "FewestMigrations"; - break; - case ::vt::vrt::collection::lb::ObjectOrderEnum::SmallObjects: - name = "SmallObjects"; - break; - case ::vt::vrt::collection::lb::ObjectOrderEnum::LargestObjects: - name = "LargestObjects"; - break; - } - return formatter::format(name, ctx); - } - }; - - // Specialize fmt::formatter for CMFTypeEnum - template <> - struct formatter<::vt::vrt::collection::lb::CMFTypeEnum> - : formatter { - template - auto format(::vt::vrt::collection::lb::CMFTypeEnum c, FormatContext& ctx) { - std::string_view name = "Unknown"; - switch (c) { - case ::vt::vrt::collection::lb::CMFTypeEnum::Original: - name = "Original"; - break; - case ::vt::vrt::collection::lb::CMFTypeEnum::NormByMax: - name = "NormByMax"; - break; - case ::vt::vrt::collection::lb::CMFTypeEnum::NormBySelf: - name = "NormBySelf"; - break; - case ::vt::vrt::collection::lb::CMFTypeEnum::NormByMaxExcludeIneligible: - name = "NormByMaxExcludeIneligible"; - break; - } - return formatter::format(name, ctx); - } - }; - - // Specialize fmt::formatter for KnowledgeEnum - template <> - struct formatter<::vt::vrt::collection::lb::KnowledgeEnum> - : formatter { - template - auto - format(::vt::vrt::collection::lb::KnowledgeEnum c, FormatContext& ctx) { - std::string_view name = "Unknown"; - switch (c) { - case ::vt::vrt::collection::lb::KnowledgeEnum::UserDefined: - name = "UserDefined"; - break; - case ::vt::vrt::collection::lb::KnowledgeEnum::Complete: - name = "Complete"; - break; - case ::vt::vrt::collection::lb::KnowledgeEnum::Log: - name = "Log"; - break; - } - return formatter::format(name, ctx); - } - }; - - // Specialize fmt::formatter for KnowledgeEnum - template <> - struct formatter<::vt::vrt::collection::lb::InformTypeEnum> - : formatter { - template - auto - format(::vt::vrt::collection::lb::InformTypeEnum c, FormatContext& ctx) { - std::string_view name = "Unknown"; - switch (c) { - case ::vt::vrt::collection::lb::InformTypeEnum::SyncInform: - name = "SyncInform"; - break; - case ::vt::vrt::collection::lb::InformTypeEnum::AsyncInform: - name = "AsyncInform"; - break; - } - return formatter::format(name, ctx); - } - }; -} // VT_FMT_NAMESPACE - #endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_TEMPEREDLB_TEMPERED_ENUMS_H*/ diff --git a/tests/unit/lb/test_lbargs_enum_conv.nompi.cc b/tests/unit/lb/test_lbargs_enum_conv.nompi.cc index c5658660d2..f6775cde10 100644 --- a/tests/unit/lb/test_lbargs_enum_conv.nompi.cc +++ b/tests/unit/lb/test_lbargs_enum_conv.nompi.cc @@ -148,7 +148,7 @@ TEST_F(TestLBArgsEnumConverter, test_enum_converter_config) { }}} // end namespace vt::tests::unit -VT_FMT_NAMESPACE { +VT_FMT_NAMESPACE_BEGIN template <> struct formatter<::vt::tests::unit::DummyEnum> : formatter { template @@ -168,4 +168,4 @@ VT_FMT_NAMESPACE { return formatter::format(name, ctx); } }; -} // VT_FMT_NAMESPACE +VT_FMT_NAMESPACE_END