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::back`.
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_BACK_HPP
0011 #define BOOST_HANA_FWD_BACK_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 last element of a non-empty and finite iterable.
0019     //! @ingroup group-Iterable
0020     //!
0021     //! Given a non-empty and finite iterable `xs` with a linearization of
0022     //! `[x1, ..., xN]`, `back(xs)` is equal to `xN`. Equivalently, `back(xs)`
0023     //! must be equivalent to `at_c<N-1>(xs)`, and that regardless of the
0024     //! value category of `xs` (`back` must respect the reference semantics
0025     //! of `at`).
0026     //!
0027     //!
0028     //! Example
0029     //! -------
0030     //! @include example/back.cpp
0031 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0032     constexpr auto back = [](auto&& xs) -> decltype(auto) {
0033         return tag-dispatched;
0034     };
0035 #else
0036     template <typename It, typename = void>
0037     struct back_impl : back_impl<It, when<true>> { };
0038 
0039     struct back_t {
0040         template <typename Xs>
0041         constexpr decltype(auto) operator()(Xs&& xs) const;
0042     };
0043 
0044     BOOST_HANA_INLINE_VARIABLE constexpr back_t back{};
0045 #endif
0046 }} // end namespace boost::hana
0047 
0048 #endif // !BOOST_HANA_FWD_BACK_HPP