summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/concepts/diagnostic1.C
blob: 0552c4b06238489131b6c9bdd0aa8e05873fb389 (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
// PR c++/67159
// { dg-options "-std=c++1z -fconcepts" }

template <class T, class U>
concept bool SameAs = __is_same_as(T, U);

template <class T>
concept bool R1 = requires (T& t) {
  { t.begin() } -> T
  { t.end() } -> SameAs<T*>;
};

template <class T>
concept bool R2 = requires (T& t) {
  { t.end() } -> SameAs<T*>;
};

struct foo {
  int* begin();
  int* end();
};

R1{T}
constexpr bool f() { return true; }

R2{T}
constexpr bool g() { return true; }

static_assert(f<foo>());	// { dg-error "" }
static_assert(g<foo>());	// { dg-error "" }