Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:43:39

0001 /*!
0002 @file
0003 Defines `boost::hana::remove`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_REMOVE_HPP
0011 #define BOOST_HANA_REMOVE_HPP
0012 
0013 #include <boost/hana/fwd/remove.hpp>
0014 
0015 #include <boost/hana/concept/monad_plus.hpp>
0016 #include <boost/hana/config.hpp>
0017 #include <boost/hana/core/dispatch.hpp>
0018 #include <boost/hana/equal.hpp>
0019 #include <boost/hana/filter.hpp>
0020 #include <boost/hana/functional/compose.hpp>
0021 #include <boost/hana/not.hpp>
0022 
0023 
0024 namespace boost { namespace hana {
0025     //! @cond
0026     template <typename Xs, typename Value>
0027     constexpr auto remove_t::operator()(Xs&& xs, Value&& value) const {
0028         using M = typename hana::tag_of<Xs>::type;
0029         using Remove = BOOST_HANA_DISPATCH_IF(remove_impl<M>,
0030             hana::MonadPlus<M>::value
0031         );
0032 
0033         #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
0034             static_assert(hana::MonadPlus<M>::value,
0035             "hana::remove(xs, value) requires 'xs' to be a MonadPlus");
0036         #endif
0037 
0038         return Remove::apply(static_cast<Xs&&>(xs),
0039                              static_cast<Value&&>(value));
0040     }
0041     //! @endcond
0042 
0043     template <typename M, bool condition>
0044     struct remove_impl<M, when<condition>> : default_ {
0045         template <typename Xs, typename Value>
0046         static constexpr auto apply(Xs&& xs, Value&& value) {
0047             return hana::filter(static_cast<Xs&&>(xs),
0048                     hana::compose(hana::not_,
0049                                   hana::equal.to(static_cast<Value&&>(value))));
0050         }
0051     };
0052 }} // end namespace boost::hana
0053 
0054 #endif // !BOOST_HANA_REMOVE_HPP