3 Forward declares `boost::hana::find_if`.
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)
10 #ifndef BOOST_HANA_FWD_FIND_IF_HPP
11 #define BOOST_HANA_FWD_FIND_IF_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Finds the value associated to the first key satisfying a predicate.
19 //! @ingroup group-Searchable
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.
27 //! The structure to be searched.
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`.
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;
45 template <typename S, typename = void>
46 struct find_if_impl : find_if_impl<S, when<true>> { };
49 template <typename Xs, typename Pred>
50 constexpr auto operator()(Xs&& xs, Pred&& pred) const;
53 constexpr find_if_t find_if{};
55 BOOST_HANA_NAMESPACE_END
57 #endif // !BOOST_HANA_FWD_FIND_IF_HPP