]> git.proxmox.com Git - ceph.git/blame_incremental - ceph/src/boost/boost/hana/fwd/first.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / hana / fwd / first.hpp
... / ...
CommitLineData
1/*!
2@file
3Forward declares `boost::hana::first`.
4
5@copyright Louis Dionne 2013-2017
6Distributed 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
17namespace boost { namespace hana {
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 BOOST_HANA_INLINE_VARIABLE constexpr first_t first{};
46#endif
47}} // end namespace boost::hana
48
49#endif // !BOOST_HANA_FWD_FIRST_HPP