You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 line
1017 B

  1. #pragma once
  2. #include <cpputils/mp/misc/when.h>
  3. #include <cpputils/mp/misc/tag_of.h>
  4. #include <cpputils/mp/misc/default.h>
  5. namespace utl {
  6. namespace mp {
  7. namespace __impl
  8. {
  9. struct second_t
  10. {
  11. template<typename T>
  12. constexpr auto operator()(T&& t) const;
  13. };
  14. }
  15. constexpr __impl::second_t second { };
  16. namespace __impl
  17. {
  18. template <typename T, typename = void>
  19. struct second_impl
  20. : second_impl<T, when<true>>
  21. { };
  22. template <typename T, bool condition>
  23. struct second_impl<T, when<condition>>
  24. : default_
  25. {
  26. template <typename ...Args>
  27. static constexpr auto apply(Args&& ...) = delete;
  28. };
  29. template<typename T>
  30. constexpr auto second_t::operator()(T&& t) const
  31. {
  32. using tag = tag_of<T>;
  33. using second = second_impl<tag>;
  34. return second::apply(std::forward<T>(t));
  35. }
  36. }
  37. }
  38. }