LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
QTime.hpp
Go to the documentation of this file.
1/*
2 * This code is a modified version of Benjamin Jurke's work in 2015. You can read his blog post
3 * here:
4 * https://benjaminjurke.com/content/articles/2015/compile-time-numerical-unit-dimension-checking/
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
10#pragma once
11
13
14namespace okapi {
15QUANTITY_TYPE(0, 0, 1, 0, QTime)
16
17constexpr QTime second(1.0); // SI base unit
18constexpr QTime millisecond = second / 1000;
19constexpr QTime minute = 60 * second;
20constexpr QTime hour = 60 * minute;
21constexpr QTime day = 24 * hour;
22
23inline namespace literals {
24constexpr QTime operator"" _s(long double x) {
25 return QTime(x);
26}
27constexpr QTime operator"" _ms(long double x) {
28 return static_cast<double>(x) * millisecond;
29}
30constexpr QTime operator"" _min(long double x) {
31 return static_cast<double>(x) * minute;
32}
33constexpr QTime operator"" _h(long double x) {
34 return static_cast<double>(x) * hour;
35}
36constexpr QTime operator"" _day(long double x) {
37 return static_cast<double>(x) * day;
38}
39constexpr QTime operator"" _s(unsigned long long int x) {
40 return QTime(static_cast<double>(x));
41}
42constexpr QTime operator"" _ms(unsigned long long int x) {
43 return static_cast<double>(x) * millisecond;
44}
45constexpr QTime operator"" _min(unsigned long long int x) {
46 return static_cast<double>(x) * minute;
47}
48constexpr QTime operator"" _h(unsigned long long int x) {
49 return static_cast<double>(x) * hour;
50}
51constexpr QTime operator"" _day(unsigned long long int x) {
52 return static_cast<double>(x) * day;
53}
54} // namespace literals
55} // namespace okapi
#define QUANTITY_TYPE(_Mdim, _Ldim, _Tdim, _Adim, name)
Definition RQuantity.hpp:84
constexpr QTime millisecond
Definition QTime.hpp:18
constexpr QTime hour
Definition QTime.hpp:20
constexpr QTime day
Definition QTime.hpp:21
@ x
Roll Axis.
constexpr QTime minute
Definition QTime.hpp:19
constexpr QTime second(1.0)