[flang-commits] [PATCH] D158957: [flang][runtime] Avoid dependency on libc++ for `std::__libcpp_verbose_abort`

Markus Mützel via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Sep 1 11:24:11 PDT 2023


mmuetzel added a comment.

I might have misunderstood your prior comment. But didn't you write that calling `std::get` on a `std::variant` would lead to this function being pulled in?
Isn't that the case with the template I pointed to earlier?
In `io-stmt.h`:

  template <typename A> A *get_if() const {
    return common::visit(
        [](auto &x) -> A * {
          if constexpr (std::is_convertible_v<decltype(x.get()), A &>) {
            return &x.get();
          }
          return nullptr;
        },
        u_);
  }

where `u_` is a `std::variant`.
IIUC, `common::visit` is from `flang/Common/visit.h`:

  template <typename VISITOR, typename... VARIANT>
  inline auto visit(VISITOR &&visitor, VARIANT &&...u)
      -> decltype(visitor(std::get<0>(std::forward<VARIANT>(u))...)) {
    using Result = decltype(visitor(std::get<0>(std::forward<VARIANT>(u))...));
    if constexpr (sizeof...(u) == 1) {
      static constexpr std::size_t high{
          (std::variant_size_v<std::decay_t<decltype(u)>> * ...) - 1};
      return Log2VisitHelper<0, high, Result>(std::forward<VISITOR>(visitor),
          u.index()..., std::forward<VARIANT>(u)...);
    } else {
      // TODO: figure out how to do multiple variant arguments
      return ::std::visit(
          std::forward<VISITOR>(visitor), std::forward<VARIANT>(u)...);
    }
  }

Wouldn't that call `std::get` on a `std::variant`?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158957/new/

https://reviews.llvm.org/D158957



More information about the flang-commits mailing list