3 Defines `boost::hana::adjust`.
5 @copyright Louis Dionne 2013-2017
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_HANA_ADJUST_HPP
11 #define BOOST_HANA_ADJUST_HPP
13 #include <boost/hana/fwd/adjust.hpp>
15 #include <boost/hana/adjust_if.hpp>
16 #include <boost/hana/concept/functor.hpp>
17 #include <boost/hana/config.hpp>
18 #include <boost/hana/core/dispatch.hpp>
19 #include <boost/hana/equal.hpp>
22 BOOST_HANA_NAMESPACE_BEGIN
24 template <typename Xs, typename Value, typename F>
25 constexpr auto adjust_t::operator()(Xs&& xs, Value&& value, F&& f) const {
26 using S = typename hana::tag_of<Xs>::type;
27 using Adjust = BOOST_HANA_DISPATCH_IF(adjust_impl<S>,
28 hana::Functor<S>::value
31 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
32 static_assert(hana::Functor<S>::value,
33 "hana::adjust(xs, value, f) requires 'xs' to be a Functor");
36 return Adjust::apply(static_cast<Xs&&>(xs),
37 static_cast<Value&&>(value),
42 template <typename Fun, bool condition>
43 struct adjust_impl<Fun, when<condition>> : default_ {
44 template <typename Xs, typename Value, typename F>
45 static constexpr auto apply(Xs&& xs, Value&& value, F&& f) {
46 return hana::adjust_if(
47 static_cast<Xs&&>(xs),
48 hana::equal.to(static_cast<Value&&>(value)),
53 BOOST_HANA_NAMESPACE_END
55 #endif // !BOOST_HANA_ADJUST_HPP