| 1 |
#include <unordered_map> |
| 2 |
|
| 3 |
#if 0 |
| 4 |
|
| 5 |
template<typename Type> |
| 6 |
Type const &smaller(Type const &first, Type const &second) |
| 7 |
{ |
| 8 |
return second < first ? second : first; |
| 9 |
} |
| 10 |
|
| 11 |
#else |
| 12 |
|
| 13 |
// compile with g++ -fconcepts min.cc |
| 14 |
|
| 15 |
template <typename Type> |
| 16 |
concept bool HasOpSmaller() |
| 17 |
{ |
| 18 |
return requires(Type lhs, Type rhs) |
| 19 |
{ |
| 20 |
lhs < rhs; |
| 21 |
}; |
| 22 |
} |
| 23 |
|
| 24 |
template<HasOpSmaller Type> |
| 25 |
Type const &smaller(Type const &first, Type const &second) |
| 26 |
{ |
| 27 |
return second < first ? second : first; |
| 28 |
} |
| 29 |
|
| 30 |
#endif |
| 31 |
|
| 32 |
int main() |
| 33 |
{ |
| 34 |
std::unordered_map<int, int> umap; |
| 35 |
smaller(umap, umap); |
| 36 |
} |