Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

50 строки
1.7 KiB

  1. #pragma once
  2. #include <utility>
  3. #include <cpputils/mp/core/conditionals.h>
  4. #include <cpputils/mp/misc/tag_of.h>
  5. #include <cpputils/mp/operations/compare/less.h>
  6. #include <cpputils/mp/operations/compare/less_equal.h>
  7. #include <cpputils/mp/operations/compare/greater.h>
  8. #include <cpputils/mp/operations/compare/greater_equal.h>
  9. namespace utl {
  10. namespace mp {
  11. namespace intern {
  12. template<typename T>
  13. struct operators_orderable
  14. { static constexpr bool value = false; };
  15. }
  16. namespace operators
  17. {
  18. template<typename X, typename Y, typename = enable_if_c<
  19. intern::operators_orderable<tag_of<X>>::value &&
  20. intern::operators_orderable<tag_of<Y>>::value>>
  21. constexpr auto operator < (X&& x, Y&& y)
  22. { return less(std::forward<X>(x), std::forward<Y>(y)); }
  23. template<typename X, typename Y, typename = enable_if_c<
  24. intern::operators_orderable<tag_of<X>>::value &&
  25. intern::operators_orderable<tag_of<Y>>::value>>
  26. constexpr auto operator <= (X&& x, Y&& y)
  27. { return less_equal(std::forward<X>(x), std::forward<Y>(y)); }
  28. template<typename X, typename Y, typename = enable_if_c<
  29. intern::operators_orderable<tag_of<X>>::value &&
  30. intern::operators_orderable<tag_of<Y>>::value>>
  31. constexpr auto operator > (X&& x, Y&& y)
  32. { return greater(std::forward<X>(x), std::forward<Y>(y)); }
  33. template<typename X, typename Y, typename = enable_if_c<
  34. intern::operators_orderable<tag_of<X>>::value &&
  35. intern::operators_orderable<tag_of<Y>>::value>>
  36. constexpr auto operator >= (X&& x, Y&& y)
  37. { return greater_equal(std::forward<X>(x), std::forward<Y>(y)); }
  38. }
  39. }
  40. }