invoke.h 697 B

12345678910111213141516171819202122232425262728
  1. //
  2. // invoke.h
  3. // stream
  4. //
  5. // Created by Sam Jaffe on 4/2/23.
  6. //
  7. #pragma once
  8. #include <stream/forward.h>
  9. #include <stream/detail/macro.h>
  10. namespace stream::detail {
  11. template <typename F, typename T, typename Proj>
  12. decltype(auto) invoke(F && func, T && t, Proj && proj) {
  13. return std::invoke(FWD(func), std::invoke(FWD(proj), FWD(t)));
  14. }
  15. template <typename F, typename T1, typename T2, typename Proj1, typename Proj2>
  16. decltype(auto) invoke(F && func, T1 && t1, T2 && t2, Proj1 && proj1,
  17. Proj2 && proj2) {
  18. return std::invoke(FWD(func), std::invoke(FWD(proj1), FWD(t1)),
  19. std::invoke(FWD(proj2), FWD(t2)));
  20. }
  21. }
  22. #include <stream/detail/undef.h>