aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/concepts-requires41.C
blob: 28c976116cadd6f8c3b0be1043d59a9cbdd4be4d (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
// PR c++/117849
// { dg-do compile { target c++20 } }

template<int N>
struct array {
  constexpr int size() const { return N; }
};

struct vector {
  int _size = 3;
  constexpr int size() const { return _size; }
};

template<int N>
struct integral_constant {
  constexpr operator int() const { return N; }
};

template<class T>
concept StaticSize = requires (T& t) {
  typename integral_constant<t.size()>;
};

static_assert(StaticSize<array<5>>);
static_assert(!StaticSize<vector>);