]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/hana/count.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / hana / count.hpp
1 /*!
2 @file
3 Defines `boost::hana::count`.
4
5 @copyright Louis Dionne 2013-2017
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_COUNT_HPP
11 #define BOOST_HANA_COUNT_HPP
12
13 #include <boost/hana/fwd/count.hpp>
14
15 #include <boost/hana/concept/foldable.hpp>
16 #include <boost/hana/config.hpp>
17 #include <boost/hana/core/dispatch.hpp>
18 #include <boost/hana/count_if.hpp>
19 #include <boost/hana/equal.hpp>
20
21
22 namespace boost { namespace hana {
23 //! @cond
24 template <typename Xs, typename Value>
25 constexpr auto count_t::operator()(Xs&& xs, Value&& value) const {
26 using S = typename hana::tag_of<Xs>::type;
27 using Count = BOOST_HANA_DISPATCH_IF(count_impl<S>,
28 hana::Foldable<S>::value
29 );
30
31 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
32 static_assert(hana::Foldable<S>::value,
33 "hana::count(xs, value) requires 'xs' to be Foldable");
34 #endif
35
36 return Count::apply(static_cast<Xs&&>(xs), static_cast<Value&&>(value));
37 }
38 //! @endcond
39
40 template <typename T, bool condition>
41 struct count_impl<T, when<condition>> : default_ {
42 template <typename Xs, typename Value>
43 static constexpr auto apply(Xs&& xs, Value&& value) {
44 return hana::count_if(static_cast<Xs&&>(xs),
45 hana::equal.to(static_cast<Value&&>(value)));
46 }
47 };
48 }} // end namespace boost::hana
49
50 #endif // !BOOST_HANA_COUNT_HPP