3 Forward declares `boost::hana::take_front` and `boost::hana::take_front_c`.
5 @copyright Louis Dionne 2013-2017
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_HANA_FWD_TAKE_FRONT_HPP
11 #define BOOST_HANA_FWD_TAKE_FRONT_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
19 BOOST_HANA_NAMESPACE_BEGIN
20 //! Returns the first `n` elements of a sequence, or the whole sequence
21 //! if the sequence has less than `n` elements.
22 //! @ingroup group-Sequence
24 //! Given a `Sequence` `xs` and an `IntegralConstant` `n`, `take_front(xs, n)`
25 //! is a new sequence containing the first `n` elements of `xs`, in the
26 //! same order. If `length(xs) <= n`, the whole sequence is returned and
27 //! no error is triggered.
31 //! The sequence to take the elements from.
34 //! A non-negative `IntegralConstant` representing the number of elements
35 //! to keep in the resulting sequence.
40 //! @include example/take_front.cpp
41 #ifdef BOOST_HANA_DOXYGEN_INVOKED
42 constexpr auto take_front = [](auto&& xs, auto const& n) {
43 return tag-dispatched;
46 template <typename S, typename = void>
47 struct take_front_impl : take_front_impl<S, when<true>> { };
50 template <typename Xs, typename N>
51 constexpr auto operator()(Xs&& xs, N const& n) const;
54 constexpr take_front_t take_front{};
57 //! Equivalent to `take_front`; provided for convenience.
58 //! @ingroup group-Sequence
63 //! @include example/take_front_c.cpp
64 #ifdef BOOST_HANA_DOXYGEN_INVOKED
65 template <std::size_t n>
66 constexpr auto take_front_c = [](auto&& xs) {
67 return hana::take_front(forwarded(xs), hana::size_c<n>);
70 template <std::size_t n>
71 struct take_front_c_t;
73 template <std::size_t n>
74 constexpr take_front_c_t<n> take_front_c{};
76 BOOST_HANA_NAMESPACE_END
78 #endif // !BOOST_HANA_FWD_TAKE_FRONT_HPP