Skip to content

Commit

Permalink
Fix variant emplace with Clang19/libstdc++
Browse files Browse the repository at this point in the history
I'm not quite sure what's changed with Clang 19, but it's suddenly complaining about libstdc++12's `variant` using the non-active member of a union in constexpr.

It's possible there was such a bug in libstdc++12, but it seems weird that it wasn't picked up by either GCC12 or an older version of Clang...

Anyway, hopefully this will fix it.
  • Loading branch information
tcbrindle committed Nov 5, 2024
1 parent a298e22 commit e20f432
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions include/flux/adaptor/flatten_with.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ namespace detail {
template <std::size_t N>
inline constexpr auto variant_emplace =
[]<typename... Types>(std::variant<Types...>& variant, auto&&... args) {
if constexpr (__cpp_lib_variant >= 202106L) {
variant.template emplace<N>(FLUX_FWD(args)...);
if (std::is_constant_evaluated()) {
variant = std::variant<Types...>(std::in_place_index<N>, FLUX_FWD(args)...); // LCOV_EXCL_LINE
} else {
if (std::is_constant_evaluated()) {
variant = std::variant<Types...>(std::in_place_index<N>, FLUX_FWD(args)...); // LCOV_EXCL_LINE
} else {
variant.template emplace<N>(FLUX_FWD(args)...);
}
variant.template emplace<N>(FLUX_FWD(args)...);
}
};

Expand Down

0 comments on commit e20f432

Please sign in to comment.