Edit: /usr/include/boost/hana/ap.hpp (2496B)
/*!
@file
Defines `boost::hana::ap`.
@copyright Louis Dionne 2013-2017
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_AP_HPP
#define BOOST_HANA_AP_HPP
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
BOOST_HANA_NAMESPACE_BEGIN
template
struct ap_impl> : default_ {
template
static constexpr auto apply(Args&& ...args) = delete;
};
//! @cond
template
constexpr decltype(auto) ap_t::operator()(F&& f, X&& x) const {
using Function = typename hana::tag_of::type;
using Value = typename hana::tag_of::type;
using Ap = BOOST_HANA_DISPATCH_IF(ap_impl,
hana::Applicative::value && hana::Applicative::value
);
#ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
static_assert(hana::Applicative::value,
"hana::ap(f, x) requires 'f' to be an Applicative");
static_assert(hana::Applicative::value,
"hana::ap(f, x) requires 'x' to be an Applicative");
#endif
return Ap::apply(static_cast(f), static_cast(x));
}
template
constexpr decltype(auto) ap_t::operator()(F&& f, Xs&& ...xs) const {
static_assert(sizeof...(xs) >= 1,
"hana::ap must be called with at least two arguments");
return detail::variadic::foldl1(
*this,
hana::transform(static_cast(f), hana::curry),
static_cast(xs)...
);
}
//! @endcond
template
struct ap_impl::value>> {
template
static constexpr decltype(auto) apply(F&& f, X&& x) {
return hana::chain(
static_cast(f),
hana::partial(hana::transform, static_cast(x))
);
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_AP_HPP