]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/hana/fwd/count_if.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / hana / fwd / count_if.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::count_if`.
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_FWD_COUNT_IF_HPP
11 #define BOOST_HANA_FWD_COUNT_IF_HPP
12
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
15
16
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Return the number of elements in the structure for which the
19 //! `predicate` is satisfied.
20 //! @ingroup group-Foldable
21 //!
22 //! Specifically, returns an object of an unsigned integral type, or
23 //! a `Constant` holding such an object, which represents the number
24 //! of elements in the structure satisfying the given `predicate`.
25 //!
26 //!
27 //! @param xs
28 //! The structure whose elements are counted.
29 //!
30 //! @param predicate
31 //! A function called as `predicate(x)`, where `x` is an element of the
32 //! structure, and returning a `Logical` representing whether `x` should
33 //! be counted.
34 //!
35 //!
36 //! Example
37 //! -------
38 //! @include example/count_if.cpp
39 #ifdef BOOST_HANA_DOXYGEN_INVOKED
40 constexpr auto count_if = [](auto&& xs, auto&& predicate) {
41 return tag-dispatched;
42 };
43 #else
44 template <typename T, typename = void>
45 struct count_if_impl : count_if_impl<T, when<true>> { };
46
47 struct count_if_t {
48 template <typename Xs, typename Pred>
49 constexpr auto operator()(Xs&& xs, Pred&& pred) const;
50 };
51
52 constexpr count_if_t count_if{};
53 #endif
54 BOOST_HANA_NAMESPACE_END
55
56 #endif // !BOOST_HANA_FWD_COUNT_IF_HPP