Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:53:03

0001 /*!
0002 @file
0003 Forward declares `boost::hana::count_if`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_FWD_COUNT_IF_HPP
0011 #define BOOST_HANA_FWD_COUNT_IF_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 #include <boost/hana/core/when.hpp>
0015 
0016 
0017 namespace boost { namespace hana {
0018     //! Return the number of elements in the structure for which the
0019     //! `predicate` is satisfied.
0020     //! @ingroup group-Foldable
0021     //!
0022     //! Specifically, returns an object of an unsigned integral type, or
0023     //! a `Constant` holding such an object, which represents the number
0024     //! of elements in the structure satisfying the given `predicate`.
0025     //!
0026     //!
0027     //! @param xs
0028     //! The structure whose elements are counted.
0029     //!
0030     //! @param predicate
0031     //! A function called as `predicate(x)`, where `x` is an element of the
0032     //! structure, and returning a `Logical` representing whether `x` should
0033     //! be counted.
0034     //!
0035     //!
0036     //! Example
0037     //! -------
0038     //! @include example/count_if.cpp
0039 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0040     constexpr auto count_if = [](auto&& xs, auto&& predicate) {
0041         return tag-dispatched;
0042     };
0043 #else
0044     template <typename T, typename = void>
0045     struct count_if_impl : count_if_impl<T, when<true>> { };
0046 
0047     struct count_if_t {
0048         template <typename Xs, typename Pred>
0049         constexpr auto operator()(Xs&& xs, Pred&& pred) const;
0050     };
0051 
0052     BOOST_HANA_INLINE_VARIABLE constexpr count_if_t count_if{};
0053 #endif
0054 }} // end namespace boost::hana
0055 
0056 #endif // !BOOST_HANA_FWD_COUNT_IF_HPP