]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Forward declares `boost::hana::take_while`. | |
4 | ||
5 | @copyright Louis Dionne 2013-2016 | |
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) | |
8 | */ | |
9 | ||
10 | #ifndef BOOST_HANA_FWD_TAKE_WHILE_HPP | |
11 | #define BOOST_HANA_FWD_TAKE_WHILE_HPP | |
12 | ||
13 | #include <boost/hana/config.hpp> | |
14 | #include <boost/hana/core/when.hpp> | |
15 | ||
16 | ||
17 | BOOST_HANA_NAMESPACE_BEGIN | |
18 | //! Take elements from a sequence while the `predicate` is satisfied. | |
19 | //! @ingroup group-Sequence | |
20 | //! | |
21 | //! Specifically, `take_while` returns a new sequence containing the | |
22 | //! longest prefix of `xs` in which all the elements satisfy the given | |
23 | //! predicate. | |
24 | //! | |
25 | //! | |
26 | //! @param xs | |
27 | //! The sequence to take elements from. | |
28 | //! | |
29 | //! @param predicate | |
30 | //! A function called as `predicate(x)`, where `x` is an element of the | |
31 | //! sequence, and returning a `Logical` representing whether `x` should be | |
32 | //! included in the resulting sequence. In the current version of the | |
33 | //! library, `predicate` has to return a `Constant Logical`. | |
34 | //! | |
35 | //! | |
36 | //! Example | |
37 | //! ------- | |
38 | //! @include example/take_while.cpp | |
39 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
40 | constexpr auto take_while = [](auto&& xs, auto&& predicate) { | |
41 | return tag-dispatched; | |
42 | }; | |
43 | #else | |
44 | template <typename S, typename = void> | |
45 | struct take_while_impl : take_while_impl<S, when<true>> { }; | |
46 | ||
47 | struct take_while_t { | |
48 | template <typename Xs, typename Pred> | |
49 | constexpr auto operator()(Xs&& xs, Pred&& pred) const; | |
50 | }; | |
51 | ||
52 | constexpr take_while_t take_while{}; | |
53 | #endif | |
54 | BOOST_HANA_NAMESPACE_END | |
55 | ||
56 | #endif // !BOOST_HANA_FWD_TAKE_WHILE_HPP |