|
|
|||
File indexing completed on 2025-12-15 09:53:03
0001 /*! 0002 @file 0003 Forward declares `boost::hana::find_if`. 0004 0005 Copyright Louis Dionne 2013-2022 0006 Distributed under the Boost Software License, Version 1.0. 0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 0008 */ 0009 0010 #ifndef BOOST_HANA_FWD_FIND_IF_HPP 0011 #define BOOST_HANA_FWD_FIND_IF_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 #include <boost/hana/core/when.hpp> 0015 0016 0017 namespace boost { namespace hana { 0018 //! Finds the value associated to the first key satisfying a predicate. 0019 //! @ingroup group-Searchable 0020 //! 0021 //! Given a `Searchable` structure `xs` and a predicate `pred`, 0022 //! `find_if(xs, pred)` returns `just` the first element whose key 0023 //! satisfies the predicate, or `nothing` if there is no such element. 0024 //! 0025 //! 0026 //! @param xs 0027 //! The structure to be searched. 0028 //! 0029 //! @param predicate 0030 //! A function called as `predicate(k)`, where `k` is a key of the 0031 //! structure, and returning whether `k` is the key of the element 0032 //! being searched for. In the current version of the library, the 0033 //! predicate has to return an `IntegralConstant` holding a value 0034 //! that can be converted to `bool`. 0035 //! 0036 //! 0037 //! Example 0038 //! ------- 0039 //! @include example/find_if.cpp 0040 #ifdef BOOST_HANA_DOXYGEN_INVOKED 0041 constexpr auto find_if = [](auto&& xs, auto&& predicate) { 0042 return tag-dispatched; 0043 }; 0044 #else 0045 template <typename S, typename = void> 0046 struct find_if_impl : find_if_impl<S, when<true>> { }; 0047 0048 struct find_if_t { 0049 template <typename Xs, typename Pred> 0050 constexpr auto operator()(Xs&& xs, Pred&& pred) const; 0051 }; 0052 0053 BOOST_HANA_INLINE_VARIABLE constexpr find_if_t find_if{}; 0054 #endif 0055 }} // end namespace boost::hana 0056 0057 #endif // !BOOST_HANA_FWD_FIND_IF_HPP
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|