All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Chrono module

Provides time utilities. More...

Classes

struct  gears::chrono::basic_stopwatch< Clock >
 A basic stopwatch for measuring time. More...
 

Detailed Description

This module defines utilities that make working with the <chrono> header easier and adds new tools for it as well.

One of the first things the chrono module is useful for is the creation of std::chrono::durations using the new C++11 user defined literal feature. The table below specifies the literals and their return value.

Literal Result
_h hours
_min minutes
_s seconds
_ms milliseconds
_us microseconds
_ns nanoseconds

All of these have unsigned long long and long double overloads. They reside in <gears/chrono/literals.hpp>. Example usage can be found below.

#include <gears/chrono/literals.hpp>
#include <thread>
#include <iostream>
// this line is required
using namespace gears::chrono::literals;
void f() {
std::this_thread::sleep_for(1.4_s); // 1.4 seconds
}
int main() {
std::cout << "Going to sleep for 1.4 seconds...";
f();
std::cout << "\nDone!";
}