result_type.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*=============================================================================
  2. Copyright (c) 2016 Paul Fultz II
  3. result_type.hpp
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #ifndef BOOST_HOF_GUARD_RESULT_TYPE_HPP
  8. #define BOOST_HOF_GUARD_RESULT_TYPE_HPP
  9. #include <boost/hof/detail/holder.hpp>
  10. #include <utility>
  11. namespace boost { namespace hof { namespace detail {
  12. template<class F, class=void>
  13. struct function_result_type
  14. {};
  15. template<class F>
  16. struct function_result_type<F, typename holder<
  17. typename F::result_type
  18. >::type>
  19. {
  20. typedef typename F::result_type result_type;
  21. };
  22. template<class F, class G, class=void>
  23. struct compose_function_result_type
  24. : function_result_type<F>
  25. {};
  26. template<class F, class G>
  27. struct compose_function_result_type<F, G, typename holder<
  28. decltype(std::declval<F>()(std::declval<typename G::result_type>()))
  29. >::type>
  30. {
  31. typedef decltype(std::declval<F>()(std::declval<typename G::result_type>())) result_type;
  32. };
  33. }}} // namespace boost::hof
  34. #endif