-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTime.inl
58 lines (49 loc) · 2.25 KB
/
Time.inl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
///
/// Langulus::Flow
/// Copyright (c) 2017 Dimo Markov <[email protected]>
/// Part of the Langulus framework, see https://langulus.com
///
/// SPDX-License-Identifier: GPL-3.0-or-later
///
#pragma once
#include "Time.hpp"
namespace Langulus
{
/// Default time point construction, defaults to the minimal possible value
LANGULUS(INLINED)
constexpr TimePoint::TimePoint() noexcept
: time_point {min()} {
using Representation = typename Base::rep;
static_assert(sizeof(Representation) == sizeof(TimePoint),
"Size mismatch");
}
/// Copy-construction
/// @param a - time point to copy
LANGULUS(INLINED)
constexpr TimePoint::TimePoint(const time_point& a) noexcept
: time_point {a} {}
/// Check if time point is something different from the default value
/// @return true if not default
LANGULUS(INLINED)
constexpr TimePoint::operator bool() const noexcept {
return *this != min();
}
/// Check if time duration is anything but zero
/// @return true if not zero
LANGULUS(INLINED)
constexpr Time::operator bool() const noexcept {
return *this != zero();
}
/// Get time duration in seconds, represented by type T
template<CT::BuiltinNumber T> LANGULUS(INLINED)
T Time::Seconds() const noexcept {
auto& asBase = static_cast<const Base&>(*this);
return std::chrono::duration<T>(asBase).count();
}
/// Get current time point
/// @return the time point
LANGULUS(INLINED)
TimePoint SteadyClock::Now() noexcept {
return steady_clock::now();
}
} // namespace Langulus