Utility Rack
Toggle main menu visibility
Main Page
Topics
Classes
Class List
Class Index
Class Hierarchy
Files
File List
File Members
All
Functions
•
All
Classes
Files
Functions
Modules
Pages
Loading...
Searching...
No Matches
include
utility
repeat.hpp
Go to the documentation of this file.
1
23
#ifndef REPEAT_HPP_INCLUDED
24
#define REPEAT_HPP_INCLUDED
25
26
#include <type_traits>
27
28
namespace
chops {
29
30
template
<
typename
F>
31
constexpr
auto
repeat(
int
n, F&& f)
32
noexcept
(
noexcept
(f(n)))
33
-> std::enable_if_t<std::is_invocable_v<F&&, int>>
34
{
35
for
(
int
i = 0; i < n; ++i)
36
{
37
f(i);
38
}
39
}
40
41
template
<
typename
F>
42
constexpr
auto
repeat(
int
n, F&& f)
43
noexcept
(
noexcept
(f()))
44
-> std::enable_if_t<!std::is_invocable_v<F&&, int>>
45
{
46
for
(
int
i = 0; i < n; ++i)
47
{
48
f();
49
}
50
}
51
52
}
// end namespace
53
54
#endif
55
Generated by
1.12.0