Advertisement
Jakowlew

Untitled

Mar 2nd, 2021
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. template <typename T>
  2. concept Foo = requires(T f, int x)
  3. {
  4.     f.bar(x);
  5. };
  6.  
  7. struct Bar { void bar(int x) {} };
  8. struct Cat { void bar(float x) {} };
  9.  
  10. template <Foo T>
  11. void kek(T f)
  12. {
  13.     f.bar(1);
  14. }
  15.  
  16. int main()
  17. {
  18.     kek(Bar{});
  19.     kek(Cat{});
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement