]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/empty.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / empty.hpp
1 /*!
2 @file
3 Defines `boost::hana::empty`.
4
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)
8 */
9
10 #ifndef BOOST_HANA_EMPTY_HPP
11 #define BOOST_HANA_EMPTY_HPP
12
13 #include <boost/hana/fwd/empty.hpp>
14
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>
20
21
22 BOOST_HANA_NAMESPACE_BEGIN
23 template <typename M>
24 struct empty_t {
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");
28 #endif
29
30 constexpr auto operator()() const {
31 using Empty = BOOST_HANA_DISPATCH_IF(empty_impl<M>,
32 hana::MonadPlus<M>::value
33 );
34
35 return Empty::apply();
36 }
37 };
38
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;
43 };
44
45 template <typename S>
46 struct empty_impl<S, when<Sequence<S>::value>> {
47 static constexpr auto apply() {
48 return hana::make<S>();
49 }
50 };
51 BOOST_HANA_NAMESPACE_END
52
53 #endif // !BOOST_HANA_EMPTY_HPP