| 1 |
#include <iostream> |
| 2 |
#include <string> |
| 3 |
#include <unordered_map> |
| 4 |
|
| 5 |
template <typename Type> |
| 6 |
concept Addable = |
| 7 |
requires(Type lh, Type rh) |
| 8 |
{ |
| 9 |
lh + rh; |
| 10 |
}; |
| 11 |
|
| 12 |
template <typename Type> |
| 13 |
concept Addable2 = |
| 14 |
Addable<Type> |
| 15 |
and |
| 16 |
requires(Type lh, Type rh) |
| 17 |
{ |
| 18 |
lh += rh; |
| 19 |
}; |
| 20 |
|
| 21 |
|
| 22 |
template<Addable Type> |
| 23 |
Type add(Type const &x, Type const &y) |
| 24 |
{ |
| 25 |
return x + y; |
| 26 |
} |
| 27 |
|
| 28 |
template<typename Type> |
| 29 |
Type add2(Type const &x, Type const &y) |
| 30 |
{ |
| 31 |
return x + y; |
| 32 |
} |
| 33 |
|
| 34 |
using namespace std; |
| 35 |
|
| 36 |
int main() |
| 37 |
{ |
| 38 |
add("one"s, "two"s); |
| 39 |
// add(unordered_map<int, int>{}, unordered_map<int, int>{}); |
| 40 |
} |