]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Forward declares `boost::hana::count`. | |
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_FWD_COUNT_HPP | |
11 | #define BOOST_HANA_FWD_COUNT_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 that compare equal to | |
19 | //! a given value. | |
20 | //! @ingroup group-Foldable | |
21 | //! | |
22 | //! Given a Foldable structure `xs` and a value `value`, `count` returns | |
23 | //! an unsigned integral, or a Constant thereof, representing the number | |
24 | //! of elements of `xs` that compare equal to `value`. For this method to | |
25 | //! be well-defined, all the elements of the structure must be Comparable | |
26 | //! with the given value. | |
27 | //! | |
28 | //! | |
29 | //! @param xs | |
30 | //! The structure whose elements are counted. | |
31 | //! | |
32 | //! @param value | |
33 | //! A value compared with each element in the structure. Elements | |
34 | //! that compare equal to this value are counted, others are not. | |
35 | //! | |
36 | //! | |
37 | //! Example | |
38 | //! ------- | |
39 | //! @include example/count.cpp | |
40 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
41 | constexpr auto count = [](auto&& xs, auto&& value) { | |
42 | return tag-dispatched; | |
43 | }; | |
44 | #else | |
45 | template <typename T, typename = void> | |
46 | struct count_impl : count_impl<T, when<true>> { }; | |
47 | ||
48 | struct count_t { | |
49 | template <typename Xs, typename Value> | |
50 | constexpr auto operator()(Xs&& xs, Value&& value) const; | |
51 | }; | |
52 | ||
53 | constexpr count_t count{}; | |
54 | #endif | |
55 | BOOST_HANA_NAMESPACE_END | |
56 | ||
57 | #endif // !BOOST_HANA_FWD_COUNT_HPP |