Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<EqualityComparable T>
- void f(const T& x, const T& y) {
- if(x == y) {
- std::cout << "stuff\n";
- }
- }
- template<Comparable T>
- void f(const T& x, const T& y) {
- if(x > y) {
- std::cout << "other\n";
- }
- }
- template<typename T>
- void f(const T& x, const T& y) {
- std::cout << "!!\n";
- }
- // compared to:
- template<typename T>
- void f(const T& x, const T& y) {
- static if(EqualityComparable<T>()) {
- if(x == y) {
- std::cout << "stuff\n";
- }
- }
- else static if(Comparable<T>()) {
- if(x > y) {
- std::cout << "other\n";
- }
- }
- else {
- std::cout << "!!\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement