MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
temperature.hpp
Go to the documentation of this file.
1
/*
2
3
Copyright 2025 Matthew Tolman
4
5
Licensed under the Apache License, Version 2.0 (the "License");
6
you may not use this file except in compliance with the License.
7
You may obtain a copy of the License at
8
9
http://www.apache.org/licenses/LICENSE-2.0
10
11
Unless required by applicable law or agreed to in writing, software
12
distributed under the License is distributed on an "AS IS" BASIS,
13
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
See the License for the specific language governing permissions and
15
limitations under the License.
16
17
*/
18
19
#ifndef MTCORE_UNITS_TEMPERATURE_HPP
20
#define MTCORE_UNITS_TEMPERATURE_HPP
21
22
#include "
mtcore/units/base.hpp
"
23
#include "
temperature.hpp
"
24
25
namespace
mtcore::units
{
26
namespace
temperature
{
27
constexpr
auto
kelvin
=
Units<Unit<dimensions::TEMPERATURE>
>{};
28
constexpr
auto
celsius
=
Units<Unit<dimensions::TEMPERATURE, std::ratio<1>
, 0, std::ratio<5463, 20>>>{};
29
constexpr
auto
fahrenheit
=
Units<Unit<dimensions::TEMPERATURE, std::ratio<5, 9>
, 0, std::ratio<45967, 100>>>{};
30
31
static_assert
(0. *
celsius
== 273.15 *
kelvin
);
32
static_assert
((0. *
fahrenheit
) >= 255.372 *
kelvin
- 0.1 *
kelvin
);
33
static_assert
((0. *
fahrenheit
) <= 255.372 *
kelvin
+ 0.1 *
kelvin
);
34
static_assert
(32. *
fahrenheit
>= 273.15 *
kelvin
- 0.01 *
kelvin
);
35
static_assert
(32. *
fahrenheit
<= 273.15 *
kelvin
+ 0.01 *
kelvin
);
36
}
// namespace temperature
37
38
MTCORE_DEF_UNIT_NAME_SYM
(temperature, kelvin, K,
"°K"
)
39
MTCORE_DEF_UNIT_NAME_SYM
(temperature, celsius, C,
"°C"
)
40
MTCORE_DEF_UNIT_NAME_SYM
(temperature, fahrenheit, F,
"°F"
)
41
}
// namespace mtcore::units
42
43
#endif
// MTCORE_UNITS_TEMPERATURE_HPP
mtcore::units::temperature
Definition
temperature.hpp:26
mtcore::units::temperature::fahrenheit
constexpr auto fahrenheit
Definition
temperature.hpp:29
mtcore::units::temperature::celsius
constexpr auto celsius
Definition
temperature.hpp:28
mtcore::units::temperature::kelvin
constexpr auto kelvin
Definition
temperature.hpp:27
mtcore::units
Base namespace for units.
Definition
angle.hpp:24
mtcore::units::Units
List of units.
Definition
units/base.hpp:80
temperature.hpp
base.hpp
MTCORE_DEF_UNIT_NAME_SYM
#define MTCORE_DEF_UNIT_NAME_SYM(NS, UNIT, ABBREV, SYM)
Definition
units/base.hpp:893
include
core
mtcore
units
temperature.hpp
Generated on Wed Jun 11 2025 16:20:21 for MT Core (C++) by
1.13.2