work around old compiler constexpr glitch

This commit is contained in:
Jean-Louis Leroy
2025-10-31 13:13:22 -04:00
parent f7d47fbd35
commit 3ef66b4b0f

View File

@@ -476,14 +476,13 @@ void registry<Policies...>::compiler<Options...>::initialize() {
registry<Policies...>::initialized = true;
}
#ifdef _MSC_VER
namespace detail {
template<bool HasTrace, typename T>
struct msvc_tuple_get;
struct tuple_get;
template<typename T>
struct msvc_tuple_get<true, T> {
struct tuple_get<true, T> {
template<class Tuple>
static decltype(auto) fn(const Tuple& t) {
return std::get<T>(t);
@@ -491,26 +490,20 @@ struct msvc_tuple_get<true, T> {
};
template<typename T>
struct msvc_tuple_get<false, T> {
struct tuple_get<false, T> {
template<class Tuple>
static decltype(auto) fn(const Tuple&) {
return T();
}
};
} // namespace detail
#endif
template<class... Policies>
template<class... Options>
registry<Policies...>::compiler<Options...>::compiler(Options... opts)
: options(opts...) {
if constexpr (has_trace) {
#ifdef _MSC_VER
tr.on = detail::msvc_tuple_get<has_trace, trace>::fn(options).on;
#else
// Even with the constexpr has_trace guard, msvc errors on this.
tr.on = std::get<trace>(options).on;
#endif
tr.on = detail::tuple_get<has_trace, trace>::fn(options).on;
}
}