Debian Codegraph @

yo/advancedtemplates/concepts/examples/requirements.cc

raw
1 #include <map>
2
3 template <typename Type>
4 concept bool Addable =
5 requires(Type lh, Type rh)
6 {
7 lh + rh;
8 };
9
10 template <typename Type>
11 concept bool Incrementable =
12 requires(Type tp)
13 {
14 ++tp;
15 };
16
17
18 //and
19 template <typename Type>
20 concept bool And =
21 requires(Type lh, Type rh)
22 {
23 lh + rh;
24 }
25 and requires(Type tp)
26 {
27 ++tp;
28 };
29
30 template <And Type>
31 Type add(Type const &lh, Type const &rh)
32 {
33 return lh + rh;
34 }
35 //=
36
37 using namespace std;
38
39 int main()
40 {
41 add(0, 0);
42 // add(map<int,int>{}, map<int,int>{});
43 }