Debian Codegraph @

yo/advancedtemplates/concepts/examples/multideclare.cc

raw
1 #include <vector>
2 #include <string>
3 #include <iostream>
4
5 using namespace std;
6
7 template <typename Type>
8 concept Subtractable =
9 requires(Type lh, Type rh)
10 {
11 lh - rh;
12 };
13
14 template <typename Type>
15 concept Addable =
16 requires(Type lh, Type rh)
17 {
18 lh + rh;
19 };
20
21 //two
22 template <typename t1, typename t2> requires Addable<t1>
23 struct Data
24 {};
25
26 template <Subtractable Type>
27 struct Data<Type, int>
28 {};
29 //=
30
31 void fun()
32 {
33 Data<vector<int>, int>{};
34 }