aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/fn-template23.C
blob: b85d4c96dab6f94069eda4969f50857fb46cd86f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// PR c++/102670
// { dg-do compile { target c++20 } }

namespace ns {
  struct S { };

  template<int I>
  constexpr int adl(const S &) {
    return I;
  }
}

namespace redirect {
  template<class T, int I>
  concept can_call_adl = requires(T t) {
    adl<I>(t);
  };

  template<int I>
  struct adl_fn {
    template<can_call_adl<I> T>
    constexpr decltype(auto) operator()(T t) const {
      return adl<I>(t);
    }
  };

  namespace {
    template<int I>
    constexpr inline adl_fn<I> adl{};
  }
}

int main() {
  static_assert(redirect::can_call_adl<ns::S, 3>);
  redirect::adl<3>(ns::S{});
}