/*============================================================================= Copyright (c) 2015 Paul Fultz II result_of.h Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #ifndef BOOST_HOF_GUARD_DETAIL_RESULT_OF_H #define BOOST_HOF_GUARD_DETAIL_RESULT_OF_H #include #include #if BOOST_HOF_HAS_MANUAL_DEDUCTION || BOOST_HOF_NO_EXPRESSION_SFINAE #include #include #include namespace boost { namespace hof { namespace detail { template struct result_of_impl {}; template struct result_of_impl< F, holder, typename std::enable_if::value>::type > { typedef decltype(std::declval()(std::declval()...)) type; }; } template struct id_ { typedef T type; }; template struct result_of : detail::result_of_impl> {}; // template // using result_of = detail::result_of_impl>; // using result_of = id_()(std::declval()...))>; }} // namespace boost::hof #endif #if BOOST_HOF_NO_EXPRESSION_SFINAE #define BOOST_HOF_SFINAE_RESULT(...) typename boost::hof::result_of<__VA_ARGS__>::type #define BOOST_HOF_SFINAE_RETURNS(...) BOOST_HOF_RETURNS_DEDUCE_NOEXCEPT(__VA_ARGS__) { return __VA_ARGS__; } #else #define BOOST_HOF_SFINAE_RESULT(...) auto #define BOOST_HOF_SFINAE_RETURNS BOOST_HOF_RETURNS #endif #if BOOST_HOF_HAS_MANUAL_DEDUCTION #define BOOST_HOF_SFINAE_MANUAL_RESULT(...) typename boost::hof::result_of<__VA_ARGS__>::type #if BOOST_HOF_HAS_COMPLETE_DECLTYPE && BOOST_HOF_HAS_MANGLE_OVERLOAD #define BOOST_HOF_SFINAE_MANUAL_RETURNS(...) BOOST_HOF_RETURNS_DEDUCE_NOEXCEPT(__VA_ARGS__) { return (__VA_ARGS__); } #else #define BOOST_HOF_SFINAE_MANUAL_RETURNS(...) BOOST_HOF_RETURNS_DEDUCE_NOEXCEPT(__VA_ARGS__) { BOOST_HOF_RETURNS_RETURN(__VA_ARGS__); } #endif #else #define BOOST_HOF_SFINAE_MANUAL_RESULT BOOST_HOF_SFINAE_RESULT #define BOOST_HOF_SFINAE_MANUAL_RETURNS BOOST_HOF_SFINAE_RETURNS #endif #endif