|
|
|||
File indexing completed on 2025-12-15 09:53:03
0001 /*! 0002 @file 0003 Forward declares `boost::hana::drop_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_DROP_BACK_HPP 0011 #define BOOST_HANA_FWD_DROP_BACK_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 #include <boost/hana/core/when.hpp> 0015 0016 0017 namespace boost { namespace hana { 0018 //! Drop the last `n` elements of a finite sequence, and return the rest. 0019 //! @ingroup group-Sequence 0020 //! 0021 //! Given a finite `Sequence` `xs` with a linearization of `[x1, ..., xm]` 0022 //! and a non-negative `IntegralConstant` `n`, `drop_back(xs, n)` is a 0023 //! sequence with the same tag as `xs` whose linearization is 0024 //! `[x1, ..., xm-n]`. If `n` is not given, it defaults to an 0025 //! `IntegralConstant` with a value equal to `1`. 0026 //! 0027 //! In case `length(xs) <= n`, `drop_back` will simply drop the whole 0028 //! sequence without failing, thus returning an empty sequence. 0029 //! 0030 //! 0031 //! @param xs 0032 //! The sequence from which elements are dropped. 0033 //! 0034 //! @param n 0035 //! A non-negative `IntegralConstant` representing the number of elements 0036 //! to be dropped from the end of the sequence. If `n` is not given, it 0037 //! defaults to an `IntegralConstant` with a value equal to `1`. 0038 //! 0039 //! 0040 //! Example 0041 //! ------- 0042 //! @include example/drop_back.cpp 0043 #ifdef BOOST_HANA_DOXYGEN_INVOKED 0044 constexpr auto drop_back = [](auto&& xs[, auto const& n]) { 0045 return tag-dispatched; 0046 }; 0047 #else 0048 template <typename S, typename = void> 0049 struct drop_back_impl : drop_back_impl<S, when<true>> { }; 0050 0051 struct drop_back_t { 0052 template <typename Xs, typename N> 0053 constexpr auto operator()(Xs&& xs, N const& n) const; 0054 0055 template <typename Xs> 0056 constexpr auto operator()(Xs&& xs) const; 0057 }; 0058 0059 BOOST_HANA_INLINE_VARIABLE constexpr drop_back_t drop_back{}; 0060 #endif 0061 }} // end namespace boost::hana 0062 0063 #endif // !BOOST_HANA_FWD_DROP_BACK_HPP
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|