summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/concepts-memtmpl6.C
blob: 0e09ae6ed4c3a77cad93d637ec28b768d168d5a4 (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
// PR c++/105842
// { dg-do compile { target c++20 } }

template<class T>
struct S {
  static void func1() requires __is_same(T, int);
  static void func1() requires (!__is_same(T, int));

  static void func2() requires false && false;
  static void func2() requires false;

  template<class...> static void tmpl1() requires __is_same(T, int);
  template<class...> static void tmpl1() requires (!__is_same(T, int));

  template<class... Us> static void tmpl2() requires (sizeof...(Us) == 1);
  template<class... Us> static void tmpl2() requires (sizeof...(Us) == 2);

  static void foo() {
    // Both calls resolve to the first overload at instantiation time.
    func1();
    tmpl1();
  }

  static void bar() {
    // We can check and reject both calls ahead of time since the functions'
    // constraints don't depend on outer template parameters.
    func2(); // { dg-error "no match" }
    tmpl2(); // { dg-error "no match" }
  }
};

int main() {
  S<int>::foo();
}