view gcc/testsuite/g++.dg/cpp2a/concepts-fn3.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
line wrap: on
line source

// { dg-do compile { target c++2a } }

template<typename T>
concept type = true;

template<typename T, typename U>
concept same_as = __is_same_as(T, U);

template<typename T>
concept integral = __is_same_as(T, int);

template<typename... Ts>
concept all_integral = (integral<Ts> && ...);

void f1(integral auto... args) { }
void f2(all_integral auto... args) { }

template<type T> requires true
void f3(T, integral auto... args) { }

template<type T>
struct S
{
  void f1(integral auto... args) { }
  void f2(all_integral auto... args) { }

  template<type U> requires true
  void f3(U, integral auto... args) { }
};

int main()
{
  f1(1, 2, 3);
  f1(1, 2, 3u); // { dg-error "" }
  f2(1, 2, 3);
  f2(1, 2, 3u); // { dg-error "" }
  f3(1, 2, 3);
  f3(1, 2, 3u); // { dg-error "" }
  f3(1u, 2, 3);

  S<void> s;
  s.f1(1, 2, 3);
  s.f1(1, 2, 3u); // { dg-error "no matching function" }
  s.f2(1, 2, 3);
  s.f2(1, 2, 3u); // { dg-error "no matching function" }
  s.f3(1, 2, 3);
  s.f3(1, 2, 3u); // { dg-error "no matching function" }
  s.f3(1u, 2, 3);
}