]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/include/boost/hana/fwd/repeat.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / fwd / repeat.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Forward declares `boost::hana::repeat`.
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_REPEAT_HPP
11#define BOOST_HANA_FWD_REPEAT_HPP
12
13#include <boost/hana/config.hpp>
14#include <boost/hana/core/when.hpp>
15
16
17BOOST_HANA_NAMESPACE_BEGIN
18 //! Invokes a nullary function `n` times.
19 //! @ingroup group-IntegralConstant
20 //!
21 //! Given an `IntegralConstant` `n` and a nullary function `f`,
22 //! `repeat(n, f)` will call `f` `n` times. In particular, any
23 //! decent compiler should expand `repeat(n, f)` to
24 //! @code
25 //! f(); f(); ... f(); // n times total
26 //! @endcode
27 //!
28 //!
29 //! @param n
30 //! An `IntegralConstant` holding a non-negative value representing
31 //! the number of times `f` should be repeatedly invoked.
32 //!
33 //! @param f
34 //! A function to repeatedly invoke `n` times. `f` is allowed to have
35 //! side effects.
36 //!
37 //!
38 //! Example
39 //! -------
40 //! @include example/repeat.cpp
41#ifdef BOOST_HANA_DOXYGEN_INVOKED
42 constexpr auto repeat = [](auto const& n, auto&& f) -> void {
43 f(); f(); ... f(); // n times total
44 };
45#else
46 template <typename N, typename = void>
47 struct repeat_impl : repeat_impl<N, when<true>> { };
48
49 struct repeat_t {
50 template <typename N, typename F>
51 constexpr void operator()(N const& n, F&& f) const;
52 };
53
54 constexpr repeat_t repeat{};
55#endif
56BOOST_HANA_NAMESPACE_END
57
58#endif // !BOOST_HANA_FWD_REPEAT_HPP