1 /*! 2 @file 3 Forward declares `boost::hana::find`. 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_HPP 11 #define BOOST_HANA_FWD_FIND_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 given key in a structure. 19 //! @ingroup group-Searchable 20 //! 21 //! Given a `key` and a `Searchable` structure, `find` returns the `just` 22 //! the first value whose key is equal to the given `key`, or `nothing` if 23 //! there is no such key. Comparison is done with `equal`. `find` satisfies 24 //! the following: 25 //! @code 26 //! find(xs, key) == find_if(xs, equal.to(key)) 27 //! @endcode 28 //! 29 //! 30 //! @param xs 31 //! The structure to be searched. 32 //! 33 //! @param key 34 //! A key to be searched for in the structure. The key has to be 35 //! `Comparable` with the other keys of the structure. In the current 36 //! version of the library, the comparison of `key` with any other key 37 //! of the structure must return a compile-time `Logical`. 38 //! 39 //! 40 //! Example 41 //! ------- 42 //! @include example/find.cpp 43 #ifdef BOOST_HANA_DOXYGEN_INVOKED __anon9b4500460102(auto&& xs, auto const& key) 44 constexpr auto find = [](auto&& xs, auto const& key) { 45 return tag-dispatched; 46 }; 47 #else 48 template <typename S, typename = void> 49 struct find_impl : find_impl<S, when<true>> { }; 50 51 struct find_t { 52 template <typename Xs, typename Key> 53 constexpr auto operator()(Xs&& xs, Key const& key) const; 54 }; 55 56 constexpr find_t find{}; 57 #endif 58 BOOST_HANA_NAMESPACE_END 59 60 #endif // !BOOST_HANA_FWD_FIND_HPP 61