Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qtaggedtime_p.h
Go to the documentation of this file.
1
// Copyright (C) 2025 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
ifndef
QTAGGEDTIME_P_H
5
#
define
QTAGGEDTIME_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
"qcompare.h"
19
20
QT_BEGIN_NAMESPACE
21
22
template
<
typename
ValueType,
typename
ThisType,
typename
AmendedType = ThisType>
23
class
BaseTime
24
{
25
public
:
26
constexpr
ValueType get()
const
noexcept
{
return
m_value; }
27
28
constexpr
BaseTime(ValueType value)
noexcept
: m_value(value) { }
29
constexpr
BaseTime(
const
ThisType &other)
noexcept
: m_value(other.m_value) { }
30
31
constexpr
ThisType &operator=(
const
ThisType &other)
noexcept
32
{
33
m_value = other.m_value;
34
return
static_cast
<ThisType &>(*
this
);
35
}
36
37
friend
bool
comparesEqual(
const
ThisType &lhs,
const
ThisType &rhs)
noexcept
38
{
39
return
lhs.m_value == rhs.m_value;
40
}
41
42
friend
constexpr
Qt::strong_ordering compareThreeWay(
const
ThisType &lhs,
43
const
ThisType &rhs)
noexcept
44
{
45
return
qCompareThreeWay(lhs.m_value, rhs.m_value);
46
}
47
48
Q_DECLARE_STRONGLY_ORDERED(ThisType);
49
50
constexpr
ThisType operator-()
const
{
return
ThisType(-m_value); }
51
52
friend
constexpr
ThisType operator+(
const
ThisType &lhs,
const
AmendedType &rhs)
noexcept
53
{
54
return
ThisType(lhs.m_value + rhs.get());
55
}
56
57
template
<
typename
T = ThisType, std::enable_if_t<!std::is_same_v<AmendedType, T>> * =
nullptr
>
58
friend
constexpr
ThisType operator+(
const
AmendedType &lhs,
const
ThisType &rhs)
noexcept
59
{
60
return
ThisType(lhs.get() + rhs.m_value);
61
}
62
63
friend
constexpr
ThisType operator-(
const
ThisType &lhs,
const
AmendedType &rhs)
noexcept
64
{
65
return
ThisType(lhs.m_value - rhs.get());
66
}
67
68
friend
constexpr
ThisType &operator+=(ThisType &lhs,
const
AmendedType &rhs)
noexcept
69
{
70
lhs.m_value += rhs.get();
71
return
lhs;
72
}
73
74
friend
constexpr
ThisType &operator-=(ThisType &lhs,
const
AmendedType &rhs)
noexcept
75
{
76
lhs.m_value -= rhs.get();
77
return
lhs;
78
}
79
80
static
constexpr
ThisType zero() {
return
ThisType(ValueType{}); }
81
82
private
:
83
ValueType m_value;
84
};
85
86
template
<
typename
ValueType,
typename
Tag>
87
class
QTaggedTimePoint
;
88
89
template
<
typename
ValueType,
typename
Tag>
90
class
QTaggedDuration
:
public
BaseTime
<
ValueType
,
QTaggedDuration
<
ValueType
,
Tag
>>
91
{
92
public
:
93
using
TimePoint
=
QTaggedTimePoint
<ValueType, Tag>;
94
using
BaseTime
<
ValueType
,
QTaggedDuration
>::
BaseTime
;
95
96
constexpr
TimePoint
asTimePoint
()
const
noexcept
{
return
TimePoint
(
this
->get()); }
97
};
98
99
template
<
typename
ValueType,
typename
Tag>
100
class
QTaggedTimePoint
101
:
public
BaseTime
<
ValueType
,
QTaggedTimePoint
<
ValueType
,
Tag
>,
QTaggedDuration
<
ValueType
,
Tag
>>
102
{
103
public
:
104
using
Duration
=
QTaggedDuration
<ValueType, Tag>;
105
using
Base
=
BaseTime
<
ValueType
,
QTaggedTimePoint
,
Duration
>;
106
using
Base
::
Base
;
107
108
friend
constexpr
Duration
operator
-(
const
QTaggedTimePoint
&lhs,
109
const
QTaggedTimePoint
&rhs)
noexcept
110
{
111
return
Duration
(lhs.get() - rhs.get());
112
}
113
114
constexpr
Duration
asDuration
()
const
noexcept
{
return
Duration
(
this
->get()); }
115
};
116
117
QT_END_NAMESPACE
118
119
#
endif
// QTAGGEDTIME_P_H
QTaggedDuration
Definition
qtaggedtime_p.h:91
QTaggedDuration::asTimePoint
constexpr TimePoint asTimePoint() const noexcept
Definition
qtaggedtime_p.h:96
QTaggedDuration::TimePoint
QTaggedTimePoint< ValueType, Tag > TimePoint
Definition
qtaggedtime_p.h:93
QTaggedTimePoint
Definition
qtaggedtime_p.h:102
QTaggedTimePoint::asDuration
constexpr Duration asDuration() const noexcept
Definition
qtaggedtime_p.h:114
QTaggedTimePoint::operator-
friend constexpr Duration operator-(const QTaggedTimePoint &lhs, const QTaggedTimePoint &rhs) noexcept
Definition
qtaggedtime_p.h:108
QTaggedTimePoint::Duration
QTaggedDuration< ValueType, Tag > Duration
Definition
qtaggedtime_p.h:104
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtmultimedia
src
multimedia
qtaggedtime_p.h
Generated on
for Qt by
1.18.0