/*! @file Defines `boost::hana::tap`. @copyright Louis Dionne 2013-2016 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_TAP_HPP #define BOOST_HANA_TAP_HPP #include #include #include #include #include #include BOOST_HANA_NAMESPACE_BEGIN template struct tap_t { #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(hana::Monad::value, "hana::tap requires 'M' to be a Monad"); #endif template constexpr auto operator()(F&& f) const { using Tap = BOOST_HANA_DISPATCH_IF(tap_impl, hana::Monad::value ); return Tap::apply(static_cast(f)); } }; namespace detail { template struct tap_helper { template constexpr auto operator()(F&& f, X&& x) const { (void)static_cast(f)(x); return hana::lift(static_cast(x)); } }; } template struct tap_impl> : default_ { template static constexpr auto apply(F&& f) { return hana::partial(detail::tap_helper{}, static_cast(f)); } }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_TAP_HPP