]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/include/boost/hana/fwd/span.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / fwd / span.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Forward declares `boost::hana::span`.
4
5@copyright Louis Dionne 2013-2016
6Distributed 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_SPAN_HPP
11#define BOOST_HANA_FWD_SPAN_HPP
12
13#include <boost/hana/config.hpp>
14#include <boost/hana/core/when.hpp>
15#include <boost/hana/detail/nested_by_fwd.hpp>
16
17
18BOOST_HANA_NAMESPACE_BEGIN
19 //! Returns a `Product` containing the longest prefix of a sequence
20 //! satisfying a predicate, and the rest of the sequence.
21 //! @ingroup group-Sequence
22 //!
23 //! The first component of the returned `Product` is a sequence for which
24 //! all elements satisfy the given predicate. The second component of the
25 //! returned `Product` is a sequence containing the remainder of the
26 //! argument. Both or either sequences may be empty, depending on the
27 //! input argument. More specifically,
28 //! @code
29 //! span(xs, predicate) == make_pair(take_while(xs, predicate),
30 //! drop_while(xs, predicate))
31 //! @endcode
32 //! except that `make_pair` may be an arbitrary `Product`.
33 //!
34 //!
35 //! Signature
36 //! ---------
37 //! Given a `Sequence` `S(T)`, a `Logical` `Bool` and a predicate
38 //! \f$ T \to Bool \f$, `span` has the following signature:
39 //! \f[
40 //! \mathtt{span} : S(T) \times (T \to Bool) \to S(T) \times S(T)
41 //! \f]
42 //!
43 //! @param xs
44 //! The sequence to break into two parts.
45 //!
46 //! @param predicate
47 //! A function called as `predicate(x)`, where `x` is an element of the
48 //! sequence, and returning a `Logical. In the current implementation of
49 //! the library, `predicate` has to return a compile-time `Logical`.
50 //!
51 //!
52 //! Syntactic sugar (`span.by`)
53 //! ---------------------------
54 //! `span` can be called in an alternate way, which provides a nice syntax
55 //! in some cases where the predicate is short:
56 //! @code
57 //! span.by(predicate, xs) == span(xs, predicate)
58 //! span.by(predicate) == span(-, predicate)
59 //! @endcode
60 //!
61 //! where `span(-, predicate)` denotes the partial application of
62 //! `span` to `predicate`.
63 //!
64 //!
65 //! Example
66 //! -------
67 //! @include example/span.cpp
68#ifdef BOOST_HANA_DOXYGEN_INVOKED
69 constexpr auto span = [](auto&& xs, auto&& predicate) {
70 return tag-dispatched;
71 };
72#else
73 template <typename S, typename = void>
74 struct span_impl : span_impl<S, when<true>> { };
75
76 struct span_t : detail::nested_by<span_t> {
77 template <typename Xs, typename Pred>
78 constexpr auto operator()(Xs&& xs, Pred&& pred) const;
79 };
80
81 constexpr span_t span{};
82#endif
83BOOST_HANA_NAMESPACE_END
84
85#endif // !BOOST_HANA_FWD_SPAN_HPP