]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/include/boost/hana/prefix.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / prefix.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Defines `boost::hana::prefix`.
4
5@copyright Louis Dionne 2013-2016
6Distributed under the Boost Software License, Version 1.0.
7(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8 */
9
10#ifndef BOOST_HANA_PREFIX_HPP
11#define BOOST_HANA_PREFIX_HPP
12
13#include <boost/hana/fwd/prefix.hpp>
14
15#include <boost/hana/append.hpp>
16#include <boost/hana/chain.hpp>
17#include <boost/hana/concept/monad_plus.hpp>
18#include <boost/hana/config.hpp>
19#include <boost/hana/core/dispatch.hpp>
20#include <boost/hana/functional/partial.hpp>
21#include <boost/hana/lift.hpp>
22
23
24BOOST_HANA_NAMESPACE_BEGIN
25 //! @cond
26 template <typename Xs, typename Pref>
27 constexpr auto prefix_t::operator()(Xs&& xs, Pref&& pref) const {
28 using M = typename hana::tag_of<Xs>::type;
29 using Prefix = BOOST_HANA_DISPATCH_IF(prefix_impl<M>,
30 hana::MonadPlus<M>::value
31 );
32
33 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
34 static_assert(hana::MonadPlus<M>::value,
35 "hana::prefix(xs, pref) requires 'xs' to be a MonadPlus");
36 #endif
37
38 return Prefix::apply(static_cast<Xs&&>(xs), static_cast<Pref&&>(pref));
39 }
40 //! @endcond
41
42 template <typename M, bool condition>
43 struct prefix_impl<M, when<condition>> : default_ {
44 template <typename Xs, typename Z>
45 static constexpr decltype(auto) apply(Xs&& xs, Z&& z) {
46 return hana::chain(static_cast<Xs&&>(xs),
47 hana::partial(hana::append, hana::lift<M>(static_cast<Z&&>(z))));
48 }
49 };
50BOOST_HANA_NAMESPACE_END
51
52#endif // !BOOST_HANA_PREFIX_HPP