Skip to content

Instantly share code, notes, and snippets.

@iFrag
Created May 18, 2018 21:00
Show Gist options
  • Save iFrag/f562235a584a1abcb61fb37484b7da9c to your computer and use it in GitHub Desktop.
Save iFrag/f562235a584a1abcb61fb37484b7da9c to your computer and use it in GitHub Desktop.
class A {
public:
int add(const A &value) {
return 0;
}
};
class B {
public:
int pridaj(const B &value) {
return 0;
}
};
template <typename T>
concept bool Addable = requires(T a) {
{a.add(a)} -> int
} || requires(T a) {
{a.pridaj(a)} -> int
};
int add(Addable a, Addable b) {
return a.pridaj(b);
}
int main() {
f(2, 2);
B a, b;
add(a, b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment