https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106398

--- Comment #1 from Justin Bassett <jbassett271 at gmail dot com> ---
Sorry about the repetition of the code example. That was some kind of bug in
the website or browser where the pasted text did not show up except for the
last copy. Let's give that code snippet one more time to make it more clearly
delineated:

#define FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)

template <bool B>
struct bool_t { static constexpr bool value = B; };

template <typename T>
struct set {
  bool contains(T const&) const { return true; }
};

template <typename T>
void intersect(set<T> const& lhs, set<T> const& rhs) {
  auto f = [&]<typename T1>(T1&& _1) noexcept(decltype([] {
      return bool_t<noexcept(rhs.contains(_1))>{};
  }(FWD(_1)))::value) {
      return rhs.contains(_1);
  };
  f(1);
}

int main() 
{
    set<int> a, b;
    intersect(a, b);
}

Reply via email to