File indexing completed on 2025-01-18 09:38:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_HANA_EMPTY_HPP
0011 #define BOOST_HANA_EMPTY_HPP
0012
0013 #include <boost/hana/fwd/empty.hpp>
0014
0015 #include <boost/hana/concept/monad_plus.hpp>
0016 #include <boost/hana/concept/sequence.hpp>
0017 #include <boost/hana/config.hpp>
0018 #include <boost/hana/core/dispatch.hpp>
0019 #include <boost/hana/core/make.hpp>
0020
0021
0022 namespace boost { namespace hana {
0023
0024 template <typename M>
0025 constexpr auto empty_t<M>::operator()() const {
0026 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
0027 static_assert(hana::MonadPlus<M>::value,
0028 "hana::empty<M>() requires 'M' to be a MonadPlus");
0029 #endif
0030
0031 using Empty = BOOST_HANA_DISPATCH_IF(empty_impl<M>,
0032 hana::MonadPlus<M>::value
0033 );
0034
0035 return Empty::apply();
0036 }
0037
0038
0039 template <typename M, bool condition>
0040 struct empty_impl<M, when<condition>> : default_ {
0041 template <typename ...Args>
0042 static constexpr auto apply(Args&& ...) = delete;
0043 };
0044
0045 template <typename S>
0046 struct empty_impl<S, when<Sequence<S>::value>> {
0047 static constexpr auto apply() {
0048 return hana::make<S>();
0049 }
0050 };
0051 }}
0052
0053 #endif