Files

55 lines
1.8 KiB
C++

/*!
@file
Defines `Boost::hana::remove`.
@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 ACTIV_BOOST_HANA_REMOVE_HPP
#define ACTIV_BOOST_HANA_REMOVE_HPP
#include <ActivBoost/hana/fwd/remove.hpp>
#include <ActivBoost/hana/concept/monad_plus.hpp>
#include <ActivBoost/hana/config.hpp>
#include <ActivBoost/hana/core/dispatch.hpp>
#include <ActivBoost/hana/equal.hpp>
#include <ActivBoost/hana/filter.hpp>
#include <ActivBoost/hana/functional/compose.hpp>
#include <ActivBoost/hana/not.hpp>
namespace Boost { namespace hana {
//! @cond
template <typename Xs, typename Value>
constexpr auto remove_t::operator()(Xs&& xs, Value&& value) const {
using M = typename hana::tag_of<Xs>::type;
using Remove = ACTIV_BOOST_HANA_DISPATCH_IF(remove_impl<M>,
hana::MonadPlus<M>::value
);
#ifndef ACTIV_BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
static_assert(hana::MonadPlus<M>::value,
"hana::remove(xs, value) requires 'xs' to be a MonadPlus");
#endif
return Remove::apply(static_cast<Xs&&>(xs),
static_cast<Value&&>(value));
}
//! @endcond
template <typename M, bool condition>
struct remove_impl<M, when<condition>> : default_ {
template <typename Xs, typename Value>
static constexpr auto apply(Xs&& xs, Value&& value) {
return hana::filter(static_cast<Xs&&>(xs),
hana::compose(hana::not_,
hana::equal.to(static_cast<Value&&>(value))));
}
};
}} // end namespace Boost::hana
#endif // ACTIV_BOOST_!ACTIV_BOOST_HANA_REMOVE_HPP