Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:13:43

0001 /*!
0002 @file
0003 Forward declares `boost::hana::index_if`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Copyright Jason Rice 2017
0007 Distributed under the Boost Software License, Version 1.0.
0008 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0009  */
0010 
0011 #ifndef BOOST_HANA_FWD_INDEX_IF_HPP
0012 #define BOOST_HANA_FWD_INDEX_IF_HPP
0013 
0014 #include <boost/hana/config.hpp>
0015 #include <boost/hana/core/when.hpp>
0016 
0017 
0018 namespace boost { namespace hana {
0019     //! Finds the value associated to the first key satisfying a predicate.
0020     //! @ingroup group-Iterable
0021     //!
0022     //! Given an `Iterable` structure `xs` and a predicate `pred`,
0023     //! `index_if(xs, pred)` returns a `hana::optional` containing an `IntegralConstant`
0024     //! of the index of the first element that satisfies the predicate or nothing
0025     //! if no element satisfies the predicate.
0026     //!
0027     //!
0028     //! @param xs
0029     //! The structure to be searched.
0030     //!
0031     //! @param predicate
0032     //! A function called as `predicate(x)`, where `x` is an element of the
0033     //! `Iterable` structure and returning whether `x` is the element being
0034     //! searched for. In the current version of the library, the predicate
0035     //! has to return an `IntegralConstant` holding a value that can be
0036     //! converted to `bool`.
0037     //!
0038     //!
0039     //! Example
0040     //! -------
0041     //! @include example/index_if.cpp
0042 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0043     constexpr auto index_if = [](auto&& xs, auto&& predicate) {
0044         return tag-dispatched;
0045     };
0046 #else
0047     template <typename S, typename = void>
0048     struct index_if_impl : index_if_impl<S, when<true>> { };
0049 
0050     struct index_if_t {
0051         template <typename Xs, typename Pred>
0052         constexpr auto operator()(Xs&& xs, Pred&& pred) const;
0053     };
0054 
0055     BOOST_HANA_INLINE_VARIABLE constexpr index_if_t index_if{};
0056 #endif
0057 }} // end namespace boost::hana
0058 
0059 #endif // !BOOST_HANA_FWD_INDEX_IF_HPP
0060