| 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 | |
| 8 | #ifndef BOOST_HOF_GUARD_RESULT_TYPE_HPP |
| 9 | #define BOOST_HOF_GUARD_RESULT_TYPE_HPP |
| 10 | |
| 11 | #include <boost/hof/detail/holder.hpp> |
| 12 | #include <utility> |
| 13 | |
| 14 | namespace boost { namespace hof { namespace detail { |
| 15 | |
| 16 | template<class F, class=void> |
| 17 | struct function_result_type |
| 18 | {}; |
| 19 | |
| 20 | template<class F> |
| 21 | struct function_result_type<F, typename holder< |
| 22 | typename F::result_type |
| 23 | >::type> |
| 24 | { |
| 25 | typedef typename F::result_type result_type; |
| 26 | }; |
| 27 | |
| 28 | template<class F, class G, class=void> |
| 29 | struct compose_function_result_type |
| 30 | : function_result_type<F> |
| 31 | {}; |
| 32 | |
| 33 | template<class F, class G> |
| 34 | struct compose_function_result_type<F, G, typename holder< |
| 35 | decltype(std::declval<F>()(std::declval<typename G::result_type>())) |
| 36 | >::type> |
| 37 | { |
| 38 | typedef decltype(std::declval<F>()(std::declval<typename G::result_type>())) result_type; |
| 39 | }; |
| 40 | |
| 41 | }}} // namespace boost::hof |
| 42 | |
| 43 | #endif |
| 44 | |