neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
flicks.h
Go to the documentation of this file.
1
9#pragma once
10
11#include <chrono>
12#include <cstdint>
13#include <functional>
14
15namespace facebook {
16namespace util {
17
58
59 using flicks = std::chrono::duration<std::chrono::nanoseconds::rep,
60 std::ratio<1, 705600000>>;
61
64 std::chrono::duration_cast<flicks>(std::chrono::seconds{ 0 }) };
66 std::chrono::duration_cast<flicks>(std::chrono::seconds{ 1 }) };
68 std::chrono::duration_cast<flicks>(
69 std::chrono::duration<flicks::rep, std::ratio<1, 24>>{1}) };
71 std::chrono::duration_cast<flicks>(
72 std::chrono::duration<flicks::rep, std::ratio<1, 90>>{1}) };
73 constexpr flicks k_flicks_min_time{ std::numeric_limits<flicks::rep>::min() };
74
77 inline constexpr double to_seconds(const flicks ns) {
78 return std::chrono::duration_cast<std::chrono::duration<double>>(ns).count();
79 }
80
83 inline constexpr flicks to_flicks(const double s) {
84 return std::chrono::duration_cast<flicks>(std::chrono::duration<double>{s});
85 }
86
89 template <class Rep, class Period>
90 inline constexpr flicks flicks_cast(
91 const std::chrono::duration<Rep, Period> in_duration) {
92 return std::chrono::duration_cast<flicks>(in_duration);
93 }
94
97 struct flicks_hash {
99 using result_type = size_t;
101 return std::hash<flicks::rep>{}(s.count());
102 }
103 };
104
105} // namespace util
106} // namespace facebook
constexpr flicks k_flicks_zero_seconds
Useful constants.
Definition flicks.h:63
constexpr flicks k_flicks_one_twenty_fourth_of_second
Definition flicks.h:67
constexpr double to_seconds(const flicks ns)
Definition flicks.h:77
std::chrono::duration< std::chrono::nanoseconds::rep, std::ratio< 1, 705600000 > > flicks
Definition flicks.h:60
constexpr flicks k_flicks_one_ninetieth_of_second
Definition flicks.h:70
constexpr flicks k_flicks_one_second
Definition flicks.h:65
constexpr flicks k_flicks_min_time
Definition flicks.h:73
constexpr flicks flicks_cast(const std::chrono::duration< Rep, Period > in_duration)
Definition flicks.h:90
constexpr flicks to_flicks(const double s)
Definition flicks.h:83
result_type operator()(argument_type const &s) const
Definition flicks.h:100