3 Defines `boost::hana::empty`.
5 @copyright Louis Dionne 2013-2016
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_EMPTY_HPP
11 #define BOOST_HANA_EMPTY_HPP
13 #include <boost/hana/fwd/empty.hpp>
15 #include <boost/hana/concept/monad_plus.hpp>
16 #include <boost/hana/concept/sequence.hpp>
17 #include <boost/hana/config.hpp>
18 #include <boost/hana/core/dispatch.hpp>
19 #include <boost/hana/core/make.hpp>
22 BOOST_HANA_NAMESPACE_BEGIN
25 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
26 static_assert(hana::MonadPlus<M>::value,
27 "hana::empty<M>() requires 'M' to be a MonadPlus");
30 constexpr auto operator()() const {
31 using Empty = BOOST_HANA_DISPATCH_IF(empty_impl<M>,
32 hana::MonadPlus<M>::value
35 return Empty::apply();
39 template <typename M, bool condition>
40 struct empty_impl<M, when<condition>> : default_ {
41 template <typename ...Args>
42 static constexpr auto apply(Args&& ...) = delete;
46 struct empty_impl<S, when<Sequence<S>::value>> {
47 static constexpr auto apply() {
48 return hana::make<S>();
51 BOOST_HANA_NAMESPACE_END
53 #endif // !BOOST_HANA_EMPTY_HPP