3 Forward declares `boost::hana::first`.
5 @copyright Louis Dionne 2013-2016
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_FIRST_HPP
11 #define BOOST_HANA_FWD_FIRST_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Returns the first element of a pair.
19 //! @ingroup group-Product
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.
31 //! @include example/first.cpp
32 #ifdef BOOST_HANA_DOXYGEN_INVOKED
33 constexpr auto first = [](auto&& product) -> decltype(auto) {
34 return tag-dispatched;
37 template <typename P, typename = void>
38 struct first_impl : first_impl<P, when<true>> { };
41 template <typename Pair>
42 constexpr decltype(auto) operator()(Pair&& pair) const;
45 constexpr first_t first{};
47 BOOST_HANA_NAMESPACE_END
49 #endif // !BOOST_HANA_FWD_FIRST_HPP