]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/hana/fwd/find_if.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / hana / fwd / find_if.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::find_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_FIND_IF_HPP
11 #define BOOST_HANA_FWD_FIND_IF_HPP
12
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
15
16
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Finds the value associated to the first key satisfying a predicate.
19 //! @ingroup group-Searchable
20 //!
21 //! Given a `Searchable` structure `xs` and a predicate `pred`,
22 //! `find_if(xs, pred)` returns `just` the first element whose key
23 //! satisfies the predicate, or `nothing` if there is no such element.
24 //!
25 //!
26 //! @param xs
27 //! The structure to be searched.
28 //!
29 //! @param predicate
30 //! A function called as `predicate(k)`, where `k` is a key of the
31 //! structure, and returning whether `k` is the key of the element
32 //! being searched for. In the current version of the library, the
33 //! predicate has to return an `IntegralConstant` holding a value
34 //! that can be converted to `bool`.
35 //!
36 //!
37 //! Example
38 //! -------
39 //! @include example/find_if.cpp
40 #ifdef BOOST_HANA_DOXYGEN_INVOKED
41 constexpr auto find_if = [](auto&& xs, auto&& predicate) {
42 return tag-dispatched;
43 };
44 #else
45 template <typename S, typename = void>
46 struct find_if_impl : find_if_impl<S, when<true>> { };
47
48 struct find_if_t {
49 template <typename Xs, typename Pred>
50 constexpr auto operator()(Xs&& xs, Pred&& pred) const;
51 };
52
53 constexpr find_if_t find_if{};
54 #endif
55 BOOST_HANA_NAMESPACE_END
56
57 #endif // !BOOST_HANA_FWD_FIND_IF_HPP