]>
Commit | Line | Data |
---|---|---|
1 | /*! | |
2 | @file | |
3 | Forward declares `boost::hana::first`. | |
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_FIRST_HPP | |
11 | #define BOOST_HANA_FWD_FIRST_HPP | |
12 | ||
13 | #include <boost/hana/config.hpp> | |
14 | #include <boost/hana/core/when.hpp> | |
15 | ||
16 | ||
17 | BOOST_HANA_NAMESPACE_BEGIN | |
18 | //! Returns the first element of a pair. | |
19 | //! @ingroup group-Product | |
20 | //! | |
21 | //! Note that if the `Product` actually stores the elements it contains, | |
22 | //! `hana::first` is required to return a lvalue reference, a lvalue | |
23 | //! reference to const or a rvalue reference to the first element, where | |
24 | //! the type of reference must match that of the pair passed to `first`. | |
25 | //! If the `Product` does not store the elements it contains (i.e. it | |
26 | //! generates them on demand), this requirement is dropped. | |
27 | //! | |
28 | //! | |
29 | //! Example | |
30 | //! ------- | |
31 | //! @include example/first.cpp | |
32 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
33 | constexpr auto first = [](auto&& product) -> decltype(auto) { | |
34 | return tag-dispatched; | |
35 | }; | |
36 | #else | |
37 | template <typename P, typename = void> | |
38 | struct first_impl : first_impl<P, when<true>> { }; | |
39 | ||
40 | struct first_t { | |
41 | template <typename Pair> | |
42 | constexpr decltype(auto) operator()(Pair&& pair) const; | |
43 | }; | |
44 | ||
45 | constexpr first_t first{}; | |
46 | #endif | |
47 | BOOST_HANA_NAMESPACE_END | |
48 | ||
49 | #endif // !BOOST_HANA_FWD_FIRST_HPP |