Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*!
0002 @file
0003 Forward declares `boost::hana::take_front` and `boost::hana::take_front_c`.
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_TAKE_FRONT_HPP
0011 #define BOOST_HANA_FWD_TAKE_FRONT_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 #include <boost/hana/core/when.hpp>
0015 
0016 #include <cstddef>
0017 
0018 
0019 namespace boost { namespace hana {
0020     //! Returns the first `n` elements of a sequence, or the whole sequence
0021     //! if the sequence has less than `n` elements.
0022     //! @ingroup group-Sequence
0023     //!
0024     //! Given a `Sequence` `xs` and an `IntegralConstant` `n`, `take_front(xs, n)`
0025     //! is a new sequence containing the first `n` elements of `xs`, in the
0026     //! same order. If `length(xs) <= n`, the whole sequence is returned and
0027     //! no error is triggered.
0028     //!
0029     //!
0030     //! @param xs
0031     //! The sequence to take the elements from.
0032     //!
0033     //! @param n
0034     //! A non-negative `IntegralConstant` representing the number of elements
0035     //! to keep in the resulting sequence.
0036     //!
0037     //!
0038     //! Example
0039     //! -------
0040     //! @include example/take_front.cpp
0041 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0042     constexpr auto take_front = [](auto&& xs, auto const& n) {
0043         return tag-dispatched;
0044     };
0045 #else
0046     template <typename S, typename = void>
0047     struct take_front_impl : take_front_impl<S, when<true>> { };
0048 
0049     struct take_front_t {
0050         template <typename Xs, typename N>
0051         constexpr auto operator()(Xs&& xs, N const& n) const;
0052     };
0053 
0054     BOOST_HANA_INLINE_VARIABLE constexpr take_front_t take_front{};
0055 #endif
0056 
0057     //! Equivalent to `take_front`; provided for convenience.
0058     //! @ingroup group-Sequence
0059     //!
0060     //!
0061     //! Example
0062     //! -------
0063     //! @include example/take_front_c.cpp
0064 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0065     template <std::size_t n>
0066     constexpr auto take_front_c = [](auto&& xs) {
0067         return hana::take_front(forwarded(xs), hana::size_c<n>);
0068     };
0069 #else
0070     template <std::size_t n>
0071     struct take_front_c_t;
0072 
0073     template <std::size_t n>
0074     BOOST_HANA_INLINE_VARIABLE constexpr take_front_c_t<n> take_front_c{};
0075 #endif
0076 }} // end namespace boost::hana
0077 
0078 #endif // !BOOST_HANA_FWD_TAKE_FRONT_HPP