Quantify
An extensible C++ units library
Loading...
Searching...
No Matches
temperature.cppm
Go to the documentation of this file.
1
// Copyright (c) 2024-2025, Víctor Castillo Agüero.
2
// SPDX-License-Identifier: Apache-2.0
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License");
5
// you may not use this file except in compliance with the License.
6
// You may obtain a copy of the License at
7
//
8
// http://www.apache.org/licenses/LICENSE-2.0
9
//
10
// Unless required by applicable law or agreed to in writing, software
11
// distributed under the License is distributed on an "AS IS" BASIS,
12
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
// See the License for the specific language governing permissions and
14
// limitations under the License.
15
16
module
;
17
#include "
quantify/unit_macros.h
"
18
export
module
quantify.scales:temperature
;
19
import
quantify.core
;
20
21
export
namespace
quantify
{
24
namespace
temperature
{
25
namespace
scales
{
26
SCALE
(
kelvin
) {}
27
SCALE
(
celsius
) {}
28
SCALE
(
fahrenheit
) {}
29
}
30
31
UNIT_IN_SCALE
(
scales::kelvin::scale
,
kelvin
,
"K"
, 1, 1);
32
33
UNIT_IN_SCALE
(
scales::celsius::scale
,
celsius
,
"C"
, 1, 1);
34
UNIT_IN_SCALE
(
scales::celsius::scale
,
millicelsius
,
"mC"
, 1, 1000);
35
36
UNIT_IN_SCALE
(
scales::fahrenheit::scale
,
fahrenheit
,
"F"
, 1, 1);
37
}
38
39
}
40
41
using namespace
quantify::temperature
;
42
export
43
{
44
//@formatter:off
45
SCALE_CONVERSION
(
scales::kelvin::scale
,
scales::celsius::scale
)
46
SCALE_FORWARD_CONVERSION
(it - 273.15)
SCALE_BACKWARD_CONVERSION
(it + 273.15)
47
48
SCALE_CONVERSION
(
scales
::
celsius
::scale,
scales
::
fahrenheit
::scale)
49
SCALE_FORWARD_CONVERSION
((it * 9 / 5) + 32)
SCALE_BACKWARD_CONVERSION
((it - 32) * 5 / 9)
50
51
SCALE_CONVERSION
(
scales
::
kelvin
::scale,
scales
::
fahrenheit
::scale)
52
SCALE_FORWARD_CONVERSION
(((it - 273.15) * 9 / 5) + 32)
SCALE_BACKWARD_CONVERSION
(((it - 32) * 5 / 9) + 273.15)
53
//@formatter:on
54
}
UNIT_IN_SCALE
#define UNIT_IN_SCALE(SCALE, NAME, SYMBOL, FACTOR_NUM, FACTOR_DEN)
Definition
unit_macros.h:50
SCALE_CONVERSION
#define SCALE_CONVERSION(FROM, TO)
Definition
unit_macros.h:72
SCALE
#define SCALE(NAME)
Definition
unit_macros.h:23
SCALE_FORWARD_CONVERSION
#define SCALE_FORWARD_CONVERSION(...)
Definition
unit_macros.h:78
SCALE_BACKWARD_CONVERSION
#define SCALE_BACKWARD_CONVERSION(...)
Definition
unit_macros.h:94
quantify.core
Core components of the Quantify library.
quantify.scales
Built-in unit scales.
quantify::temperature::scales::celsius
Definition
temperature.cppm:27
quantify::temperature::scales::fahrenheit
Definition
temperature.cppm:28
quantify::temperature::scales::kelvin
Definition
temperature.cppm:26
quantify::temperature::scales
Definition
temperature.cppm:25
quantify::temperature
Definition
temperature.cppm:24
quantify
Definition
concepts.cppm:25
quantify::temperature::celsius
Definition
temperature.cppm:33
quantify::temperature::fahrenheit
Definition
temperature.cppm:36
quantify::temperature::kelvin
Definition
temperature.cppm:31
quantify::temperature::millicelsius
Definition
temperature.cppm:34
quantify::temperature::scales::celsius::scale
Definition
temperature.cppm:27
quantify::temperature::scales::fahrenheit::scale
Definition
temperature.cppm:28
quantify::temperature::scales::kelvin::scale
Definition
temperature.cppm:26
unit_macros.h
include
quantify
scales
base_units
temperature.cppm
Generated by
1.13.2