qtty-cpp 0.4.5
Header-only C++ wrapper for qtty
Loading...
Searching...
No Matches
amount.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2// Copyright (C) 2026 Vallés Puig, Ramon
3
4#pragma once
5
6#include "../ffi_core.hpp"
7
8namespace qtty {
9
10struct MoleTag {};
11struct NanomoleTag {};
12struct MicromoleTag {};
13struct MillimoleTag {};
14struct KilomoleTag {};
15
16template <> struct UnitTraits<MoleTag> {
17 static constexpr UnitId unit_id() { return UNIT_ID_MOLE; }
18 static constexpr std::string_view symbol() { return "mol"; }
19 static constexpr DimensionId dimension() { return DIMENSION_ID_AMOUNT_OF_SUBSTANCE; }
20};
21template <> struct UnitTraits<NanomoleTag> {
22 static constexpr UnitId unit_id() { return UNIT_ID_NANOMOLE; }
23 static constexpr std::string_view symbol() { return "nmol"; }
24 static constexpr DimensionId dimension() { return DIMENSION_ID_AMOUNT_OF_SUBSTANCE; }
25};
26template <> struct UnitTraits<MicromoleTag> {
27 static constexpr UnitId unit_id() { return UNIT_ID_MICROMOLE; }
28 static constexpr std::string_view symbol() { return "µmol"; }
29 static constexpr DimensionId dimension() { return DIMENSION_ID_AMOUNT_OF_SUBSTANCE; }
30};
31template <> struct UnitTraits<MillimoleTag> {
32 static constexpr UnitId unit_id() { return UNIT_ID_MILLIMOLE; }
33 static constexpr std::string_view symbol() { return "mmol"; }
34 static constexpr DimensionId dimension() { return DIMENSION_ID_AMOUNT_OF_SUBSTANCE; }
35};
36template <> struct UnitTraits<KilomoleTag> {
37 static constexpr UnitId unit_id() { return UNIT_ID_KILOMOLE; }
38 static constexpr std::string_view symbol() { return "kmol"; }
39 static constexpr DimensionId dimension() { return DIMENSION_ID_AMOUNT_OF_SUBSTANCE; }
40};
41
47
48} // namespace qtty
Core quantity template and error translation utilities.
Quantity< MoleTag > Mole
Definition amount.hpp:42
Quantity< MicromoleTag > Micromole
Definition amount.hpp:44
Quantity< KilomoleTag > Kilomole
Definition amount.hpp:46
Quantity< NanomoleTag > Nanomole
Definition amount.hpp:43
Quantity< MillimoleTag > Millimole
Definition amount.hpp:45
static constexpr DimensionId dimension()
Definition amount.hpp:39
static constexpr UnitId unit_id()
Definition amount.hpp:37
static constexpr std::string_view symbol()
Definition amount.hpp:38
static constexpr DimensionId dimension()
Definition amount.hpp:29
static constexpr std::string_view symbol()
Definition amount.hpp:28
static constexpr UnitId unit_id()
Definition amount.hpp:27
static constexpr UnitId unit_id()
Definition amount.hpp:32
static constexpr DimensionId dimension()
Definition amount.hpp:34
static constexpr std::string_view symbol()
Definition amount.hpp:33
static constexpr std::string_view symbol()
Definition amount.hpp:18
static constexpr DimensionId dimension()
Definition amount.hpp:19
static constexpr UnitId unit_id()
Definition amount.hpp:17
static constexpr UnitId unit_id()
Definition amount.hpp:22
static constexpr DimensionId dimension()
Definition amount.hpp:24
static constexpr std::string_view symbol()
Definition amount.hpp:23