Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. template <typename T>
  2. requires (T& a, const T& b, uint32_t i) {
  3. a.Update(i);
  4. {b.GetResult()} -> int32_t;
  5. }
  6. void foo(T& x)
  7. {
  8. // ...
  9. }
  10.  
  11. template <typename T>
  12. class foo_traits {
  13. template <typename U>
  14. auto check(...) -> std::false_type;
  15. template <typename U>
  16. auto check(U x) -> decltype((void)x.Update(uint32_t{}), std::true_type{});
  17. public:
  18. bool has_update = decltype(check(std::declval<T>()))::value;
  19. };
  20.  
  21. template <typename T>
  22. void foo(T& x)
  23. {
  24. static_assert(foo_traits<T>::has_update, "blah blah blah");
  25. }
  26.  
  27. template <typename T>
  28. std::enable_if_t<foo_traits<T>::has_update> foo(T& x)
  29. {
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement