3 Forward declares `boost::hana::index_if`.
5 @copyright Louis Dionne 2013-2017
6 @copyright Jason Rice 2017
7 Distributed under the Boost Software License, Version 1.0.
8 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_HANA_FWD_INDEX_IF_HPP
12 #define BOOST_HANA_FWD_INDEX_IF_HPP
14 #include <boost/hana/config.hpp>
15 #include <boost/hana/core/when.hpp>
18 BOOST_HANA_NAMESPACE_BEGIN
19 //! Finds the value associated to the first key satisfying a predicate.
20 //! @ingroup group-Iterable
22 //! Given an `Iterable` structure `xs` and a predicate `pred`,
23 //! `index_if(xs, pred)` returns a `hana::optional` containing an `IntegralConstant`
24 //! of the index of the first element that satisfies the predicate or nothing
25 //! if no element satisfies the predicate.
29 //! The structure to be searched.
32 //! A function called as `predicate(x)`, where `x` is an element of the
33 //! `Iterable` structure and returning whether `x` is the element being
34 //! searched for. In the current version of the library, the predicate
35 //! has to return an `IntegralConstant` holding a value that can be
36 //! converted to `bool`.
41 //! @include example/index_if.cpp
42 #ifdef BOOST_HANA_DOXYGEN_INVOKED
43 constexpr auto index_if = [](auto&& xs, auto&& predicate) {
44 return tag-dispatched;
47 template <typename S, typename = void>
48 struct index_if_impl : index_if_impl<S, when<true>> { };
51 template <typename Xs, typename Pred>
52 constexpr auto operator()(Xs&& xs, Pred&& pred) const;
55 constexpr index_if_t index_if{};
57 BOOST_HANA_NAMESPACE_END
59 #endif // !BOOST_HANA_FWD_INDEX_IF_HPP