diff --git a/src/thread.cpp b/src/thread.cpp index aa2af26..26c1aea 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -7,20 +7,13 @@ #include // std::random_device etc #include // std::vector -/** - * @brief Return a container with randomly initialized values. - * - * @tparam Cont Container type. - * @param count Number of container elements. - * - * @return Initialized container. - */ + template static Cont container(std::size_t count) { using T = typename Cont::value_type; - static std::random_device rd; - static std::default_random_engine dre{rd()}; + static std::random_device ranDevice; + static std::default_random_engine dre{ranDevice()}; static std::uniform_int_distribution prob_dist{ 0, std::numeric_limits::max()}; Cont container(count); @@ -29,20 +22,12 @@ static Cont container(std::size_t count) return container; } -/** - * @brief Execute a function and output its duration to standard output. - * - * @tparam F Type of function. - * @tparam Args Type of function arguments. - * @param fn Function. - * @param args Function arguments. - */ template static void timed_exec(const F& fn, Args&&... args) { using namespace std::chrono; auto now = steady_clock::now(); - fn(std::forward(args)...); + fn(std::forwaranDevice(args)...); auto elapsed = steady_clock::now() - now; auto msec = duration_cast(elapsed); std::cout << "duration: " << msec.count() << " msec\n";