Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:53:03

0001 /*!
0002 @file
0003 Forward declares `boost::hana::first`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_FWD_FIRST_HPP
0011 #define BOOST_HANA_FWD_FIRST_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 #include <boost/hana/core/when.hpp>
0015 
0016 
0017 namespace boost { namespace hana {
0018     //! Returns the first element of a pair.
0019     //! @ingroup group-Product
0020     //!
0021     //! Note that if the `Product` actually stores the elements it contains,
0022     //! `hana::first` is required to return a lvalue reference, a lvalue
0023     //! reference to const or a rvalue reference to the first element, where
0024     //! the type of reference must match that of the pair passed to `first`.
0025     //! If the `Product` does not store the elements it contains (i.e. it
0026     //! generates them on demand), this requirement is dropped.
0027     //!
0028     //!
0029     //! Example
0030     //! -------
0031     //! @include example/first.cpp
0032 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0033     constexpr auto first = [](auto&& product) -> decltype(auto) {
0034         return tag-dispatched;
0035     };
0036 #else
0037     template <typename P, typename = void>
0038     struct first_impl : first_impl<P, when<true>> { };
0039 
0040     struct first_t {
0041         template <typename Pair>
0042         constexpr decltype(auto) operator()(Pair&& pair) const;
0043     };
0044 
0045     BOOST_HANA_INLINE_VARIABLE constexpr first_t first{};
0046 #endif
0047 }} // end namespace boost::hana
0048 
0049 #endif // !BOOST_HANA_FWD_FIRST_HPP