3 Forward declares `boost::hana::at_key`.
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)
10 #ifndef BOOST_HANA_FWD_AT_KEY_HPP
11 #define BOOST_HANA_FWD_AT_KEY_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Returns the value associated to the given key in a structure, or fail.
19 //! @ingroup group-Searchable
21 //! Given a `key` and a `Searchable` structure, `at_key` returns the first
22 //! value whose key is equal to the given `key`, and fails at compile-time
23 //! if no such key exists. This requires the `key` to be compile-time
24 //! `Comparable`, exactly like for `find`. `at_key` satisfies the following:
26 //! at_key(xs, key) == find(xs, key).value()
29 //! If the `Searchable` actually stores the elements it contains, `at_key`
30 //! is required to return a lvalue reference, a lvalue reference to const
31 //! or a rvalue reference to the found value, where the type of reference
32 //! must match that of the structure passed to `at_key`. If the `Searchable`
33 //! does not store the elements it contains (i.e. it generates them on
34 //! demand), this requirement is dropped.
38 //! The structure to be searched.
41 //! A key to be searched for in the structure. The key has to be
42 //! `Comparable` with the other keys of the structure. In the current
43 //! version of the library, the comparison of `key` with any other key
44 //! of the structure must return a compile-time `Logical`.
49 //! @include example/at_key.cpp
50 #ifdef BOOST_HANA_DOXYGEN_INVOKED
51 constexpr auto at_key = [](auto&& xs, auto const& key) -> decltype(auto) {
52 return tag-dispatched;
55 template <typename S, typename = void>
56 struct at_key_impl : at_key_impl<S, when<true>> { };
59 template <typename Xs, typename Key>
60 constexpr decltype(auto) operator()(Xs&& xs, Key const& key) const;
63 constexpr at_key_t at_key{};
65 BOOST_HANA_NAMESPACE_END
67 #endif // !BOOST_HANA_FWD_AT_KEY_HPP