-
Notifications
You must be signed in to change notification settings - Fork 0
/
concept1.cpp
90 lines (65 loc) · 1.32 KB
/
concept1.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// $HOME/bin/bin/g++ -std=c++1z -o concept1 concept1.cpp
// ./concept1
// Constrained type specifiers.
// dcl.spec.auto.constr
template<typename T>
concept bool C1 = false;
template<int N>
concept bool C2 = false;
template<template<typename> typename X>
concept bool C3 = false;
template<typename T, int N>
class Array
{};
template<typename T, template<typename> typename A>
class Stack
{};
template<typename T>
class Alloc
{};
void
f1(C1); // C1 designates a placeholder type.
void
f2(Array<auto, C2>); // C2 designates a placeholder for int value.
void
f3(Stack<auto, C3>); // C3 designates a placeholder for a class template.
// #1
template<typename T>
concept bool
C()
{ return true; }
// #2
template<typename T, typename U>
concept bool
C()
{ return true; }
// #3
template<typename T>
concept bool
D = true;
// The set of concepts referred to by C includes #1 and #2;
// Concept resolution selects #1.
void
f(C);
// The concept-name D refers only to #3.
void
g(D);
// Partial-concept-id.
template<typename T, int N = 0>
concept bool
Seq = true;
void
f1(Seq<3>);
void
f2(Seq<>);
// Concept specifier.
// dcl.spec.concept
// Function concept.
template<typename T>
concept bool
F1()
{ return true; }
// Variable concept.
template<typename T>
concept bool
V1{true};