Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:14

0001 /*=============================================================================
0002     Copyright (c) 2015 Paul Fultz II
0003     result_of.h
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 
0008 #ifndef BOOST_HOF_GUARD_DETAIL_RESULT_OF_H
0009 #define BOOST_HOF_GUARD_DETAIL_RESULT_OF_H
0010 
0011 #include <boost/hof/returns.hpp>
0012 #include <boost/hof/config.hpp>
0013 
0014 #if BOOST_HOF_HAS_MANUAL_DEDUCTION || BOOST_HOF_NO_EXPRESSION_SFINAE
0015 
0016 #include <boost/hof/detail/and.hpp>
0017 #include <boost/hof/detail/holder.hpp>
0018 #include <boost/hof/detail/can_be_called.hpp>
0019 
0020 namespace boost { namespace hof { namespace detail {
0021 
0022 template<class F, class Args, class=void>
0023 struct result_of_impl {};
0024 
0025 template<class F, class... Ts>
0026 struct result_of_impl<
0027     F, 
0028     holder<Ts...>, 
0029     typename std::enable_if<can_be_called<F, typename Ts::type...>::value>::type
0030 >
0031 {
0032     typedef decltype(std::declval<F>()(std::declval<typename Ts::type>()...)) type;
0033 };
0034 }
0035 
0036 template<class T>
0037 struct id_
0038 {
0039     typedef T type;
0040 };
0041 
0042 template<class F, class... Ts>
0043 struct result_of
0044 : detail::result_of_impl<F, detail::holder<Ts...>>
0045 {};
0046 
0047 // template<class F, class... Ts>
0048 // using result_of = detail::result_of_impl<F, detail::holder<Ts...>>;
0049 // using result_of = id_<decltype(std::declval<F>()(std::declval<typename Ts::type>()...))>;
0050 
0051 }} // namespace boost::hof
0052 #endif
0053 
0054 #if BOOST_HOF_NO_EXPRESSION_SFINAE
0055 
0056 #define BOOST_HOF_SFINAE_RESULT(...) typename boost::hof::result_of<__VA_ARGS__>::type
0057 #define BOOST_HOF_SFINAE_RETURNS(...) BOOST_HOF_RETURNS_DEDUCE_NOEXCEPT(__VA_ARGS__) { return __VA_ARGS__; }
0058 
0059 #else
0060 
0061 #define BOOST_HOF_SFINAE_RESULT(...) auto
0062 #define BOOST_HOF_SFINAE_RETURNS BOOST_HOF_RETURNS
0063 
0064 #endif
0065 
0066 #if BOOST_HOF_HAS_MANUAL_DEDUCTION
0067 
0068 #define BOOST_HOF_SFINAE_MANUAL_RESULT(...) typename boost::hof::result_of<__VA_ARGS__>::type
0069 #if BOOST_HOF_HAS_COMPLETE_DECLTYPE && BOOST_HOF_HAS_MANGLE_OVERLOAD
0070 #define BOOST_HOF_SFINAE_MANUAL_RETURNS(...) BOOST_HOF_RETURNS_DEDUCE_NOEXCEPT(__VA_ARGS__) { return (__VA_ARGS__); }
0071 #else
0072 #define BOOST_HOF_SFINAE_MANUAL_RETURNS(...) BOOST_HOF_RETURNS_DEDUCE_NOEXCEPT(__VA_ARGS__) { BOOST_HOF_RETURNS_RETURN(__VA_ARGS__); }
0073 #endif
0074 
0075 #else
0076 
0077 #define BOOST_HOF_SFINAE_MANUAL_RESULT BOOST_HOF_SFINAE_RESULT
0078 #define BOOST_HOF_SFINAE_MANUAL_RETURNS BOOST_HOF_SFINAE_RETURNS
0079 
0080 #endif
0081 
0082 #endif