invoke.h 668 B

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