• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Created by Joachim on 16/04/2019.
3  *  Adapted from donated nonius code.
4  *
5  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
6  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  */
8 
9 // repeat algorithm
10 
11 #ifndef TWOBLUECUBES_CATCH_DETAIL_REPEAT_HPP_INCLUDED
12 #define TWOBLUECUBES_CATCH_DETAIL_REPEAT_HPP_INCLUDED
13 
14 #include <type_traits>
15 #include <utility>
16 
17 namespace Catch {
18     namespace Benchmark {
19         namespace Detail {
20             template <typename Fun>
21             struct repeater {
operator ()Catch::Benchmark::Detail::repeater22                 void operator()(int k) const {
23                     for (int i = 0; i < k; ++i) {
24                         fun();
25                     }
26                 }
27                 Fun fun;
28             };
29             template <typename Fun>
repeat(Fun && fun)30             repeater<typename std::decay<Fun>::type> repeat(Fun&& fun) {
31                 return { std::forward<Fun>(fun) };
32             }
33         } // namespace Detail
34     } // namespace Benchmark
35 } // namespace Catch
36 
37 #endif // TWOBLUECUBES_CATCH_DETAIL_REPEAT_HPP_INCLUDED
38