mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-07 14:14:27 +02:00
Merge branch 'master' into chiphogg/switch-to-mag
This commit is contained in:
20
.github/workflows/documentation.yml
vendored
20
.github/workflows/documentation.yml
vendored
@@ -25,16 +25,16 @@ name: Documentation
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '.github/workflows/documentation.yml'
|
||||
- 'docs/**'
|
||||
- 'src/**'
|
||||
- 'example/**'
|
||||
- ".github/workflows/documentation.yml"
|
||||
- "docs/**"
|
||||
- "src/**"
|
||||
- "example/**"
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/documentation.yml'
|
||||
- 'docs/**'
|
||||
- 'src/**'
|
||||
- 'example/**'
|
||||
- ".github/workflows/documentation.yml"
|
||||
- "docs/**"
|
||||
- "src/**"
|
||||
- "example/**"
|
||||
|
||||
env:
|
||||
CC: gcc-10
|
||||
@@ -65,7 +65,7 @@ jobs:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.8'
|
||||
python-version: "3.8"
|
||||
- name: Install Python dependencies
|
||||
run: |
|
||||
pip install -Ur docs/requirements.txt
|
||||
@@ -83,7 +83,7 @@ jobs:
|
||||
- name: Configure CMake
|
||||
working-directory: build
|
||||
run: |
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
|
||||
- name: Generate documentation
|
||||
working-directory: build
|
||||
run: |
|
||||
|
@@ -9,7 +9,7 @@
|
||||
- (!) refactor: `PrefixFamily` support removed
|
||||
- (!) refactor: `mi(naut)` renamed to `nmi`
|
||||
- (!) refactor: `knot` unit helper renamed to `kn` in FPS
|
||||
- (!) refactor: `knot` text symbol changed from `"knot"` to `"kn`"
|
||||
- (!) refactor: `knot` text symbol changed from `"knot"` to `"kn"`
|
||||
- refactor: `quantity` `op+()` and `op-()` reimplemented in terms of `reference` rather then `quantity` types
|
||||
- refactor(example): `glide_computer` now use dimensionless quantities with `ranged_representation` as `rep`
|
||||
- feat: HEP system support added (thanks [@RalphSteinhagen](https://github.com/RalphSteinhagen))
|
||||
|
@@ -44,6 +44,7 @@ set(unitsSphinxDocs
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/_static/img/downcast_1.png"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/_static/img/downcast_2.png"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/_static/img/units.svg"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/_static/img/quantity_like.svg"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG.md"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/design.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/design/directories.rst"
|
||||
@@ -88,6 +89,7 @@ set(unitsSphinxDocs
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/dimensions.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/quantities.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/quantity_kinds.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/quantity_like.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/quantity_points.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/text_output.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/units.rst"
|
||||
|
37
docs/_static/img/quantity_like.svg
vendored
Normal file
37
docs/_static/img/quantity_like.svg
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="348px" preserveAspectRatio="none" style="width:288px;height:348px;background:#FCFCFC;" version="1.1" viewBox="0 0 288 348" width="288px" zoomAndPan="magnify"><defs/><g><!--MD5=[da1b011f603b1fa92adce02fc4bac354]
|
||||
class quantity--><a href="../framework/quantities.html" target="_top" title="../framework/quantities.html" xlink:actuate="onRequest" xlink:href="../framework/quantities.html" xlink:show="new" xlink:title="../framework/quantities.html" xlink:type="simple"><g id="elem_quantity"><rect codeLine="8" fill="#F1F1F1" height="26.2969" id="quantity" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="66" x="80" y="110"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="60" x="83" y="127.9951">quantity</text></g></a><!--MD5=[18fbdc711d33f9ff282e1f4c30c050e6]
|
||||
class quantity_point--><a href="../framework/quantity_points.html" target="_top" title="../framework/quantity_points.html" xlink:actuate="onRequest" xlink:href="../framework/quantity_points.html" xlink:show="new" xlink:title="../framework/quantity_points.html" xlink:type="simple"><g id="elem_quantity_point"><rect codeLine="9" fill="#F1F1F1" height="26.2969" id="quantity_point" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="112" x="7" y="213"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="106" x="10" y="230.9951">quantity_point</text></g></a><!--MD5=[5b6ab379e9f247363b208f7c72246136]
|
||||
class quantity_kind--><a href="../framework/quantity_kinds.html" target="_top" title="../framework/quantity_kinds.html" xlink:actuate="onRequest" xlink:href="../framework/quantity_kinds.html" xlink:show="new" xlink:title="../framework/quantity_kinds.html" xlink:type="simple"><g id="elem_quantity_kind"><rect codeLine="10" fill="#F1F1F1" height="26.2969" id="quantity_kind" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="104" x="154" y="213"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="98" x="157" y="230.9951">quantity_kind</text></g></a><!--MD5=[6d322596e71f19471be4dbdd0c5e34a1]
|
||||
class quantity_point_kind--><a href="../framework/quantity_kinds.html#quantity-point-kinds" target="_top" title="../framework/quantity_kinds.html#quantity-point-kinds" xlink:actuate="onRequest" xlink:href="../framework/quantity_kinds.html#quantity-point-kinds" xlink:show="new" xlink:title="../framework/quantity_kinds.html#quantity-point-kinds" xlink:type="simple"><g id="elem_quantity_point_kind"><rect codeLine="11" fill="#F1F1F1" height="26.2969" id="quantity_point_kind" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="150" x="131" y="316"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="144" x="134" y="333.9951">quantity_point_kind</text></g></a><!--MD5=[b2a694e6474a2a9b22a2e31fbfd4909a]
|
||||
class Rep--><g id="elem_Rep"><rect fill="#F1F1F1" height="26.2969" id="Rep" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="35" x="95.5" y="7"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="29" x="98.5" y="24.9951">Rep</text></g><!--MD5=[e24fe1f9fefda9999290bb447fae99e3]
|
||||
reverse link Rep to quantity--><g id="link_Rep_quantity"><path codeLine="13" d="M113,38.526 C113,58.92 113,92.061 113,109.83 " fill="none" id="Rep-backto-quantity" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="113,33.385,109,42.385,113,38.385,117,42.385,113,33.385" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="60" x="114" y="76.0669">number()</text></g><!--MD5=[90d8d95e9adcc8fc2f6906e762b4a14d]
|
||||
reverse link quantity to quantity_point--><g id="link_quantity_quantity_point"><path codeLine="14" d="M98.633,140.033 C92.5205,147.508 85.7271,156.776 81,166 C73.1851,181.249 68.1076,200.483 65.3984,212.765 " fill="none" id="quantity-backto-quantity_point" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="101.9413,136.076,93.0996,140.4147,98.7341,139.9118,99.2369,145.5463,101.9413,136.076" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="58" x="82" y="179.0669">relative()</text></g><!--MD5=[dd075b90f0ec4f5db24762fad9b93a06]
|
||||
reverse link quantity to quantity_kind--><g id="link_quantity_quantity_kind"><path codeLine="15" d="M127.956,140.242 C146.612,160.503 178.084,194.683 194.794,212.83 " fill="none" id="quantity-backto-quantity_kind" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="124.404,136.385,127.5577,145.7153,127.7908,140.0632,133.4429,140.2964,124.404,136.385" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="67" x="167" y="179.0669">common()</text></g><!--MD5=[1acbd4671b34e1d8b20d7848e474454e]
|
||||
reverse link quantity_kind to quantity_point_kind--><g id="link_quantity_kind_quantity_point_kind"><path codeLine="16" d="M206,244.5264 C206,264.9203 206,298.0611 206,315.8296 " fill="none" id="quantity_kind-backto-quantity_point_kind" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="206,239.385,202,248.385,206,244.385,210,248.385,206,239.385" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="58" x="207" y="282.0669">relative()</text></g><!--MD5=[abc9f5195c71d2db961c2d927d457aba]
|
||||
@startuml
|
||||
skinparam monochrome true
|
||||
skinparam shadowing false
|
||||
skinparam backgroundColor #fcfcfc
|
||||
|
||||
hide members
|
||||
hide circle
|
||||
|
||||
class quantity [[../framework/quantities.html]]
|
||||
class quantity_point [[../framework/quantity_points.html]]
|
||||
class quantity_kind [[../framework/quantity_kinds.html]]
|
||||
class quantity_point_kind [[../framework/quantity_kinds.html#quantity-point-kinds]]
|
||||
|
||||
Rep <- - quantity : number()
|
||||
quantity <- - quantity_point : relative()
|
||||
quantity <- - quantity_kind : common()
|
||||
quantity_kind <- - quantity_point_kind : relative()
|
||||
@enduml
|
||||
|
||||
PlantUML version 1.2022.6beta5(Unknown compile time)
|
||||
(GPL source distribution)
|
||||
Java Runtime: Java(TM) SE Runtime Environment
|
||||
JVM: Java HotSpot(TM) 64-Bit Server VM
|
||||
Default Encoding: UTF-8
|
||||
Language: en
|
||||
Country: US
|
||||
--></g></svg>
|
After Width: | Height: | Size: 6.4 KiB |
@@ -12,6 +12,7 @@ Framework Basics
|
||||
:maxdepth: 2
|
||||
|
||||
framework/basic_concepts
|
||||
framework/quantity_like
|
||||
framework/quantities
|
||||
framework/quantity_points
|
||||
framework/quantity_kinds
|
||||
|
51
docs/framework/quantity_like.rst
Normal file
51
docs/framework/quantity_like.rst
Normal file
@@ -0,0 +1,51 @@
|
||||
.. namespace:: units
|
||||
|
||||
Quantity-like Types
|
||||
===================
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<object data="../_images/quantity_like.svg" type="image/svg+xml" class="align-center" style="max-width: 100%;"></object>
|
||||
|
||||
..
|
||||
https://www.planttext.com
|
||||
|
||||
@startuml
|
||||
|
||||
skinparam monochrome true
|
||||
skinparam shadowing false
|
||||
skinparam backgroundColor #fcfcfc
|
||||
|
||||
hide members
|
||||
hide circle
|
||||
|
||||
class quantity [[../framework/quantities.html]]
|
||||
class quantity_point [[../framework/quantity_points.html]]
|
||||
class quantity_kind [[../framework/quantity_kinds.html]]
|
||||
class quantity_point_kind [[../framework/quantity_kinds.html#quantity-point-kinds]]
|
||||
|
||||
Rep <-- quantity : number()
|
||||
quantity <-- quantity_point : relative()
|
||||
quantity <-- quantity_kind : common()
|
||||
quantity_kind <-- quantity_point_kind : relative()
|
||||
|
||||
@enduml
|
||||
|
||||
|
||||
[ISO80000]_ defines a :term:`quantity` as a:
|
||||
|
||||
Property of a phenomenon, body, or substance, where the property has a magnitude that can be expressed by
|
||||
means of a number and a reference.
|
||||
|
||||
You can use `quantity::number()` member function to get a concrete amount of a unit expressed with a specific
|
||||
representation type ``Rep``.
|
||||
|
||||
:term:`Kind of quantity <kind of quantity>` is defined as:
|
||||
|
||||
Aspect common to mutually comparable quantities.
|
||||
|
||||
We can obtain a `quantity` with a `quantity_kind::common()` member function.
|
||||
|
||||
`quantity_point` and `quantity_point_kind` are absolute quantities and quantity kinds relative to some
|
||||
specific origin. `quantity` and `quantity_point` types can be obtained from them using a ``relative()`` member
|
||||
function (`quantity_point::relative()`, `quantity_point_kind::relative()`).
|
@@ -206,26 +206,26 @@ complete list of all the :term:`SI` prefixes supported by the library::
|
||||
|
||||
namespace si {
|
||||
|
||||
struct yocto : units::prefix<yocto, "y", ratio(1, 1, -24)> {};
|
||||
struct zepto : units::prefix<zepto, "z", ratio(1, 1, -21)> {};
|
||||
struct atto : units::prefix<atto, "a", ratio(1, 1, -18)> {};
|
||||
struct femto : units::prefix<femto, "f", ratio(1, 1, -15)> {};
|
||||
struct pico : units::prefix<pico, "p", ratio(1, 1, -12)> {};
|
||||
struct nano : units::prefix<nano, "n", ratio(1, 1, -9)> {};
|
||||
struct micro : units::prefix<micro, "µ", ratio(1, 1, -6)> {};
|
||||
struct milli : units::prefix<milli, "m", ratio(1, 1, -3)> {};
|
||||
struct centi : units::prefix<centi, "c", ratio(1, 1, -2)> {};
|
||||
struct deci : units::prefix<deci, "d", ratio(1, 1, -1)> {};
|
||||
struct deca : units::prefix<deca, "da",ratio(1, 1, 1)> {};
|
||||
struct hecto : units::prefix<hecto, "h", ratio(1, 1, 2)> {};
|
||||
struct kilo : units::prefix<kilo, "k", ratio(1, 1, 3)> {};
|
||||
struct mega : units::prefix<mega, "M", ratio(1, 1, 6)> {};
|
||||
struct giga : units::prefix<giga, "G", ratio(1, 1, 9)> {};
|
||||
struct tera : units::prefix<tera, "T", ratio(1, 1, 12)> {};
|
||||
struct peta : units::prefix<peta, "P", ratio(1, 1, 15)> {};
|
||||
struct exa : units::prefix<exa, "E", ratio(1, 1, 18)> {};
|
||||
struct zetta : units::prefix<zetta, "Z", ratio(1, 1, 21)> {};
|
||||
struct yotta : units::prefix<yotta, "Y", ratio(1, 1, 24)> {};
|
||||
struct yocto : prefix<yocto, "y", ratio(1, 1, -24)> {};
|
||||
struct zepto : prefix<zepto, "z", ratio(1, 1, -21)> {};
|
||||
struct atto : prefix<atto, "a", ratio(1, 1, -18)> {};
|
||||
struct femto : prefix<femto, "f", ratio(1, 1, -15)> {};
|
||||
struct pico : prefix<pico, "p", ratio(1, 1, -12)> {};
|
||||
struct nano : prefix<nano, "n", ratio(1, 1, -9)> {};
|
||||
struct micro : prefix<micro, "µ", ratio(1, 1, -6)> {};
|
||||
struct milli : prefix<milli, "m", ratio(1, 1, -3)> {};
|
||||
struct centi : prefix<centi, "c", ratio(1, 1, -2)> {};
|
||||
struct deci : prefix<deci, "d", ratio(1, 1, -1)> {};
|
||||
struct deca : prefix<deca, "da",ratio(1, 1, 1)> {};
|
||||
struct hecto : prefix<hecto, "h", ratio(1, 1, 2)> {};
|
||||
struct kilo : prefix<kilo, "k", ratio(1, 1, 3)> {};
|
||||
struct mega : prefix<mega, "M", ratio(1, 1, 6)> {};
|
||||
struct giga : prefix<giga, "G", ratio(1, 1, 9)> {};
|
||||
struct tera : prefix<tera, "T", ratio(1, 1, 12)> {};
|
||||
struct peta : prefix<peta, "P", ratio(1, 1, 15)> {};
|
||||
struct exa : prefix<exa, "E", ratio(1, 1, 18)> {};
|
||||
struct zetta : prefix<zetta, "Z", ratio(1, 1, 21)> {};
|
||||
struct yotta : prefix<yotta, "Y", ratio(1, 1, 24)> {};
|
||||
|
||||
}
|
||||
|
||||
@@ -234,12 +234,12 @@ domain::
|
||||
|
||||
namespace iec80000 {
|
||||
|
||||
struct kibi : units::prefix<kibi, "Ki", ratio( 1'024)> {};
|
||||
struct mebi : units::prefix<mebi, "Mi", ratio( 1'048'576)> {};
|
||||
struct gibi : units::prefix<gibi, "Gi", ratio( 1'073'741'824)> {};
|
||||
struct tebi : units::prefix<tebi, "Ti", ratio( 1'099'511'627'776)> {};
|
||||
struct pebi : units::prefix<pebi, "Pi", ratio( 1'125'899'906'842'624)> {};
|
||||
struct exbi : units::prefix<exbi, "Ei", ratio(1'152'921'504'606'846'976)> {};
|
||||
struct kibi : prefix<kibi, "Ki", ratio( 1'024)> {};
|
||||
struct mebi : prefix<mebi, "Mi", ratio( 1'048'576)> {};
|
||||
struct gibi : prefix<gibi, "Gi", ratio( 1'073'741'824)> {};
|
||||
struct tebi : prefix<tebi, "Ti", ratio( 1'099'511'627'776)> {};
|
||||
struct pebi : prefix<pebi, "Pi", ratio( 1'125'899'906'842'624)> {};
|
||||
struct exbi : prefix<exbi, "Ei", ratio(1'152'921'504'606'846'976)> {};
|
||||
|
||||
}
|
||||
|
||||
@@ -301,15 +301,15 @@ will result in a different unnamed unit symbol:
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_mass, 1>,
|
||||
exponent<si::dim_length, 1>,
|
||||
exponent<si::dim_time, -1>> {}; // kg ⋅ m/s
|
||||
exponent<si::dim_time, -1>> {}; // kg⋅m/s
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_length, 1>,
|
||||
exponent<si::dim_mass, 1>,
|
||||
exponent<si::dim_time, -1>> {}; // m ⋅ kg/s
|
||||
exponent<si::dim_time, -1>> {}; // m⋅kg/s
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_time, -1>,
|
||||
exponent<si::dim_length, 1>,
|
||||
exponent<si::dim_mass, 1>> {}; // 1/s ⋅ m ⋅ kg
|
||||
exponent<si::dim_mass, 1>> {}; // 1/s⋅m⋅kg
|
||||
|
||||
where ``kilogram_metre_per_second`` is defined as::
|
||||
|
||||
@@ -323,7 +323,7 @@ However, the easiest way to define momentum is just to use the
|
||||
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_mass, 1>,
|
||||
exponent<si::dim_speed, 1>> {}; // kg ⋅ m/s
|
||||
exponent<si::dim_speed, 1>> {}; // kg⋅m/s
|
||||
|
||||
In such a case the library will do its magic and will automatically
|
||||
unpack a provided derived dimension to its base dimensions in order to
|
||||
|
@@ -212,8 +212,8 @@ only a few of many options possible.
|
||||
Copy
|
||||
^^^^
|
||||
|
||||
As **mp-units** is a C++ header-only library you can simply copy *src/include* directory to
|
||||
your source tree and use it as regular header files.
|
||||
As **mp-units** is a C++ header-only library you can simply copy all needed ``src/*/include`` subdirectories
|
||||
to your source tree.
|
||||
|
||||
.. important::
|
||||
|
||||
|
@@ -37,6 +37,7 @@ add_example(conversion_factor mp-units::core-fmt mp-units::core-io mp-units::si)
|
||||
add_example(custom_systems mp-units::core-io mp-units::si)
|
||||
add_example(hello_units mp-units::core-fmt mp-units::core-io mp-units::si mp-units::si-international)
|
||||
add_example(measurement mp-units::core-io mp-units::si)
|
||||
add_example(si_constants mp-units::core-fmt mp-units::si)
|
||||
|
||||
if(NOT ${projectPrefix}LIBCXX)
|
||||
add_subdirectory(glide_computer)
|
||||
|
@@ -38,20 +38,20 @@ concept QuantityOrQuantityPoint =
|
||||
units::Quantity<T> || units::QuantityPoint<T>; // TODO Should it also account for `kinds`?
|
||||
|
||||
template<typename... Qs>
|
||||
inline constexpr bool are_derivatives = false;
|
||||
inline constexpr bool are_time_derivatives = false;
|
||||
|
||||
template<typename Q>
|
||||
inline constexpr bool are_derivatives<Q> = true;
|
||||
inline constexpr bool are_time_derivatives<Q> = true;
|
||||
|
||||
template<typename Q1, typename Q2, typename... Qs>
|
||||
inline constexpr bool are_derivatives<Q1, Q2, Qs...> =
|
||||
inline constexpr bool are_time_derivatives<Q1, Q2, Qs...> =
|
||||
units::DimensionOfT<typename decltype(Q1::reference / Q2::reference)::dimension,
|
||||
units::isq::dim_time> && // TODO Think on how to simplify this
|
||||
are_derivatives<Q2, Qs...>;
|
||||
are_time_derivatives<Q2, Qs...>;
|
||||
|
||||
// state
|
||||
template<QuantityOrQuantityPoint... QQPs>
|
||||
requires(sizeof...(QQPs) > 0) && (sizeof...(QQPs) <= 3) && are_derivatives<QQPs...>
|
||||
requires(sizeof...(QQPs) > 0) && (sizeof...(QQPs) <= 3) && are_time_derivatives<QQPs...>
|
||||
struct state {
|
||||
std::tuple<QQPs...> variables_;
|
||||
constexpr state(QQPs... qqps) : variables_(std::move(qqps)...) {}
|
||||
|
40
example/si_constants.cpp
Normal file
40
example/si_constants.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/format.h>
|
||||
#include <units/isq/si/constants.h>
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units::isq::si::si2019;
|
||||
|
||||
std::cout << "The seven defining constants of the SI and the seven corresponding units they define:\n";
|
||||
std::cout << STD_FMT::format("- hyperfine transition frequency of Cs: {:%.0Q %q}\n",
|
||||
hyperfine_structure_transition_frequency<>);
|
||||
std::cout << STD_FMT::format("- speed of light in vacuum: {:%.0Q %q}\n", speed_of_light<>);
|
||||
std::cout << STD_FMT::format("- Planck constant: {}\n", planck_constant<>);
|
||||
std::cout << STD_FMT::format("- elementary charge: {}\n", elementary_charge<>);
|
||||
std::cout << STD_FMT::format("- Boltzmann constant: {}\n", boltzmann_constant<>);
|
||||
std::cout << STD_FMT::format("- Avogadro constant: {}\n", avogadro_constant<>);
|
||||
std::cout << STD_FMT::format("- luminous efficacy: {}\n", luminous_efficacy<>);
|
||||
}
|
@@ -27,12 +27,12 @@
|
||||
|
||||
namespace units::detail {
|
||||
|
||||
// same_scaled_units
|
||||
// compatible_units
|
||||
template<typename ExpList, Unit... Us>
|
||||
inline constexpr bool same_scaled_units = false;
|
||||
inline constexpr bool compatible_units = false;
|
||||
|
||||
template<typename... Es, Unit... Us>
|
||||
inline constexpr bool same_scaled_units<exponent_list<Es...>, Us...> = (UnitOf<Us, typename Es::dimension> && ...);
|
||||
inline constexpr bool compatible_units<exponent_list<Es...>, Us...> = (UnitOf<Us, typename Es::dimension> && ...);
|
||||
|
||||
// derived_scaled_unit
|
||||
|
||||
|
@@ -42,7 +42,7 @@ constexpr auto operator_text()
|
||||
if constexpr (Divide && NegativeExpCount == 1) {
|
||||
return basic_fixed_string("/");
|
||||
} else {
|
||||
return basic_symbol_text(" ⋅ ", " ");
|
||||
return basic_symbol_text("⋅", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -449,6 +449,9 @@ template<typename D, typename U, typename Rep>
|
||||
explicit(false) quantity(Rep&&)->quantity<D, U, Rep>;
|
||||
#endif
|
||||
|
||||
template<typename D, typename U, typename Rep>
|
||||
explicit(false) quantity(quantity<D, U, Rep>)->quantity<D, U, Rep>;
|
||||
|
||||
template<Representation Rep>
|
||||
explicit(false) quantity(Rep)->quantity<dim_one, one, Rep>;
|
||||
|
||||
|
@@ -142,7 +142,7 @@ struct derived_unit : downcast_dispatch<Child, scaled_unit<as_magnitude<1>(), Ch
|
||||
* @tparam URest the units for the rest of dimensions from the recipe
|
||||
*/
|
||||
template<typename Child, DerivedDimension Dim, NamedUnit U, NamedUnit... URest>
|
||||
requires detail::same_scaled_units<typename Dim::recipe, U, URest...>
|
||||
requires detail::compatible_units<typename Dim::recipe, U, URest...>
|
||||
struct derived_scaled_unit : downcast_dispatch<Child, detail::derived_scaled_unit<Dim, U, URest...>> {
|
||||
static constexpr auto symbol = detail::derived_symbol_text<Dim, U, URest...>();
|
||||
};
|
||||
|
@@ -26,11 +26,11 @@
|
||||
|
||||
namespace units::isq::iec80000 {
|
||||
|
||||
struct kibi : units::prefix<kibi, "Ki", ratio(1'024)> {};
|
||||
struct mebi : units::prefix<mebi, "Mi", ratio(1'048'576)> {};
|
||||
struct gibi : units::prefix<gibi, "Gi", ratio(1'073'741'824)> {};
|
||||
struct tebi : units::prefix<tebi, "Ti", ratio(1'099'511'627'776)> {};
|
||||
struct pebi : units::prefix<pebi, "Pi", ratio(1'125'899'906'842'624)> {};
|
||||
struct exbi : units::prefix<exbi, "Ei", ratio(1'152'921'504'606'846'976)> {};
|
||||
struct kibi : prefix<kibi, "Ki", ratio(1'024)> {};
|
||||
struct mebi : prefix<mebi, "Mi", ratio(1'048'576)> {};
|
||||
struct gibi : prefix<gibi, "Gi", ratio(1'073'741'824)> {};
|
||||
struct tebi : prefix<tebi, "Ti", ratio(1'099'511'627'776)> {};
|
||||
struct pebi : prefix<pebi, "Pi", ratio(1'125'899'906'842'624)> {};
|
||||
struct exbi : prefix<exbi, "Ei", ratio(1'152'921'504'606'846'976)> {};
|
||||
|
||||
} // namespace units::isq::iec80000
|
||||
|
@@ -49,6 +49,7 @@ add_units_module(
|
||||
include/units/isq/dimensions/inductance.h
|
||||
include/units/isq/dimensions/length.h
|
||||
include/units/isq/dimensions/luminance.h
|
||||
include/units/isq/dimensions/luminous_flux.h
|
||||
include/units/isq/dimensions/luminous_intensity.h
|
||||
include/units/isq/dimensions/magnetic_flux.h
|
||||
include/units/isq/dimensions/magnetic_induction.h
|
||||
|
@@ -48,6 +48,7 @@
|
||||
#include <units/isq/dimensions/inductance.h>
|
||||
#include <units/isq/dimensions/length.h>
|
||||
#include <units/isq/dimensions/luminance.h>
|
||||
#include <units/isq/dimensions/luminous_flux.h>
|
||||
#include <units/isq/dimensions/luminous_intensity.h>
|
||||
#include <units/isq/dimensions/magnetic_flux.h>
|
||||
#include <units/isq/dimensions/magnetic_induction.h>
|
||||
|
36
src/systems/isq/include/units/isq/dimensions/luminous_flux.h
Normal file
36
src/systems/isq/include/units/isq/dimensions/luminous_flux.h
Normal file
@@ -0,0 +1,36 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/concepts.h>
|
||||
#include <units/isq/dimensions/power.h>
|
||||
|
||||
namespace units::isq {
|
||||
|
||||
template<typename Child, Unit U, typename... Dims>
|
||||
using dim_luminous_flux = dim_power<Child, U, Dims...>;
|
||||
|
||||
template<typename T>
|
||||
concept LuminousFlux = QuantityOfT<T, dim_luminous_flux>;
|
||||
|
||||
} // namespace units::isq
|
@@ -50,6 +50,7 @@ add_units_module(
|
||||
include/units/isq/si/inductance.h
|
||||
include/units/isq/si/length.h
|
||||
include/units/isq/si/luminance.h
|
||||
include/units/isq/si/luminous_flux.h
|
||||
include/units/isq/si/luminous_intensity.h
|
||||
include/units/isq/si/magnetic_flux.h
|
||||
include/units/isq/si/magnetic_induction.h
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include <units/isq/si/electric_charge.h>
|
||||
#include <units/isq/si/energy.h>
|
||||
#include <units/isq/si/frequency.h>
|
||||
#include <units/isq/si/luminous_flux.h>
|
||||
#include <units/isq/si/power.h>
|
||||
#include <units/isq/si/speed.h>
|
||||
#include <units/isq/si/thermodynamic_temperature.h>
|
||||
@@ -51,10 +52,10 @@ template<Representation Rep = double>
|
||||
inline constexpr auto speed_of_light = speed<metre_per_second, Rep>(299'792'458);
|
||||
|
||||
template<Representation Rep = double>
|
||||
inline constexpr auto hyperfine_structure_transition_frequency = frequency<hertz, Rep>(9'192'631'770);
|
||||
inline constexpr auto hyperfine_structure_transition_frequency = frequency<hertz, Rep>(Rep{9'192'631'770});
|
||||
|
||||
// template<Representation Rep = double>
|
||||
// inline constexpr auto luminous_efficacy = 683_q_lm / 1_q_W;
|
||||
template<Representation Rep = double>
|
||||
inline constexpr auto luminous_efficacy = luminous_flux<lumen, Rep>(683) / power<watt, Rep>(1);
|
||||
|
||||
template<Representation Rep = double>
|
||||
inline constexpr auto standard_gravity = acceleration<metre_per_second_sq, Rep>(9.80665);
|
||||
|
89
src/systems/si/include/units/isq/si/luminous_flux.h
Normal file
89
src/systems/si/include/units/isq/si/luminous_flux.h
Normal file
@@ -0,0 +1,89 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <units/isq/si/power.h>
|
||||
#include <units/quantity.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/symbol_text.h>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
#include <units/isq/si/prefixes.h>
|
||||
#include <units/unit.h>
|
||||
|
||||
namespace units::isq::si {
|
||||
|
||||
// TODO Is this correct? Should we account for steradian here? How?
|
||||
|
||||
struct lumen : named_scaled_unit<lumen, "lm", ratio(1, 683), watt> {};
|
||||
|
||||
using dim_luminous_flux = dim_power;
|
||||
|
||||
template<UnitOf<dim_luminous_flux> U, Representation Rep = double>
|
||||
using luminous_flux = power<U, Rep>;
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// lm
|
||||
constexpr auto operator"" _q_lm(unsigned long long l)
|
||||
{
|
||||
gsl_ExpectsAudit(std::in_range<std::int64_t>(l));
|
||||
return luminous_flux<lumen, std::int64_t>(static_cast<std::int64_t>(l));
|
||||
}
|
||||
constexpr auto operator"" _q_lm(long double l) { return luminous_flux<lumen, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
#endif // UNITS_NO_LITERALS
|
||||
|
||||
#ifndef UNITS_NO_REFERENCES
|
||||
|
||||
namespace luminous_flux_references {
|
||||
|
||||
inline constexpr auto lm = reference<dim_luminous_flux, lumen>{};
|
||||
|
||||
} // namespace luminous_flux_references
|
||||
|
||||
namespace references {
|
||||
|
||||
using namespace luminous_flux_references;
|
||||
|
||||
} // namespace references
|
||||
|
||||
#endif // UNITS_NO_REFERENCES
|
||||
|
||||
} // namespace units::isq::si
|
||||
|
||||
#ifndef UNITS_NO_ALIASES
|
||||
|
||||
namespace units::aliases::isq::si::inline luminous_flux {
|
||||
|
||||
template<Representation Rep = double>
|
||||
using lm = units::isq::si::luminous_flux<units::isq::si::lumen, Rep>;
|
||||
|
||||
} // namespace units::aliases::isq::si::inline luminous_flux
|
||||
|
||||
#endif // UNITS_NO_ALIASES
|
@@ -27,26 +27,26 @@
|
||||
namespace units::isq::si {
|
||||
|
||||
// clang-format off
|
||||
struct yocto : units::prefix<yocto, "y", ratio(1, 1, -24)> {};
|
||||
struct zepto : units::prefix<zepto, "z", ratio(1, 1, -21)> {};
|
||||
struct atto : units::prefix<atto, "a", ratio(1, 1, -18)> {};
|
||||
struct femto : units::prefix<femto, "f", ratio(1, 1, -15)> {};
|
||||
struct pico : units::prefix<pico, "p", ratio(1, 1, -12)> {};
|
||||
struct nano : units::prefix<nano, "n", ratio(1, 1, -9)> {};
|
||||
struct micro : units::prefix<micro, basic_symbol_text{"\u00b5", "u"}, ratio(1, 1, -6)> {};
|
||||
struct milli : units::prefix<milli, "m", ratio(1, 1, -3)> {};
|
||||
struct centi : units::prefix<centi, "c", ratio(1, 1, -2)> {};
|
||||
struct deci : units::prefix<deci, "d", ratio(1, 1, -1)> {};
|
||||
struct deca : units::prefix<deca, "da", ratio(1, 1, 1)> {};
|
||||
struct hecto : units::prefix<hecto, "h", ratio(1, 1, 2)> {};
|
||||
struct kilo : units::prefix<kilo, "k", ratio(1, 1, 3)> {};
|
||||
struct mega : units::prefix<mega, "M", ratio(1, 1, 6)> {};
|
||||
struct giga : units::prefix<giga, "G", ratio(1, 1, 9)> {};
|
||||
struct tera : units::prefix<tera, "T", ratio(1, 1, 12)> {};
|
||||
struct peta : units::prefix<peta, "P", ratio(1, 1, 15)> {};
|
||||
struct exa : units::prefix<exa, "E", ratio(1, 1, 18)> {};
|
||||
struct zetta : units::prefix<zetta, "Z", ratio(1, 1, 21)> {};
|
||||
struct yotta : units::prefix<yotta, "Y", ratio(1, 1, 24)> {};
|
||||
struct yocto : prefix<yocto, "y", ratio(1, 1, -24)> {};
|
||||
struct zepto : prefix<zepto, "z", ratio(1, 1, -21)> {};
|
||||
struct atto : prefix<atto, "a", ratio(1, 1, -18)> {};
|
||||
struct femto : prefix<femto, "f", ratio(1, 1, -15)> {};
|
||||
struct pico : prefix<pico, "p", ratio(1, 1, -12)> {};
|
||||
struct nano : prefix<nano, "n", ratio(1, 1, -9)> {};
|
||||
struct micro : prefix<micro, basic_symbol_text{"\u00b5", "u"}, ratio(1, 1, -6)> {};
|
||||
struct milli : prefix<milli, "m", ratio(1, 1, -3)> {};
|
||||
struct centi : prefix<centi, "c", ratio(1, 1, -2)> {};
|
||||
struct deci : prefix<deci, "d", ratio(1, 1, -1)> {};
|
||||
struct deca : prefix<deca, "da", ratio(1, 1, 1)> {};
|
||||
struct hecto : prefix<hecto, "h", ratio(1, 1, 2)> {};
|
||||
struct kilo : prefix<kilo, "k", ratio(1, 1, 3)> {};
|
||||
struct mega : prefix<mega, "M", ratio(1, 1, 6)> {};
|
||||
struct giga : prefix<giga, "G", ratio(1, 1, 9)> {};
|
||||
struct tera : prefix<tera, "T", ratio(1, 1, 12)> {};
|
||||
struct peta : prefix<peta, "P", ratio(1, 1, 15)> {};
|
||||
struct exa : prefix<exa, "E", ratio(1, 1, 18)> {};
|
||||
struct zetta : prefix<zetta, "Z", ratio(1, 1, 21)> {};
|
||||
struct yotta : prefix<yotta, "Y", ratio(1, 1, 24)> {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace units::isq::si
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include <units/isq/si/charge_density.h>
|
||||
#include <units/isq/si/concentration.h>
|
||||
#include <units/isq/si/conductance.h>
|
||||
#include <units/isq/si/constants.h>
|
||||
#include <units/isq/si/current_density.h>
|
||||
#include <units/isq/si/density.h>
|
||||
#include <units/isq/si/dynamic_viscosity.h>
|
||||
@@ -40,35 +41,37 @@
|
||||
#include <units/isq/si/electric_current.h>
|
||||
#include <units/isq/si/electric_field_strength.h>
|
||||
#include <units/isq/si/energy.h>
|
||||
#include <units/isq/si/length.h>
|
||||
#include <units/isq/si/luminous_intensity.h>
|
||||
#include <units/isq/si/mass.h>
|
||||
#include <units/isq/si/thermodynamic_temperature.h>
|
||||
#include <units/isq/si/time.h>
|
||||
// TODO Add when downcasting issue is solved (collides with pressure)
|
||||
// #include <units/isq/si/energy_density.h>
|
||||
#include <units/isq/si/force.h>
|
||||
#include <units/isq/si/frequency.h>
|
||||
#include <units/isq/si/heat_capacity.h>
|
||||
#include <units/isq/si/inductance.h>
|
||||
#include <units/isq/si/length.h>
|
||||
#include <units/isq/si/luminance.h>
|
||||
#include <units/isq/si/luminous_flux.h>
|
||||
#include <units/isq/si/luminous_intensity.h>
|
||||
#include <units/isq/si/magnetic_flux.h>
|
||||
#include <units/isq/si/magnetic_induction.h>
|
||||
#include <units/isq/si/mass.h>
|
||||
#include <units/isq/si/molar_energy.h>
|
||||
#include <units/isq/si/momentum.h>
|
||||
#include <units/isq/si/permeability.h>
|
||||
#include <units/isq/si/permittivity.h>
|
||||
#include <units/isq/si/power.h>
|
||||
#include <units/isq/si/pressure.h>
|
||||
// TODO Add when downcasting issue is solved (collides with frequency)
|
||||
// #include <units/isq/si/radioactivity.h>
|
||||
#include <units/isq/si/constants.h>
|
||||
#include <units/isq/si/prefixes.h>
|
||||
#include <units/isq/si/pressure.h>
|
||||
#include <units/isq/si/resistance.h>
|
||||
#include <units/isq/si/speed.h>
|
||||
#include <units/isq/si/surface_tension.h>
|
||||
#include <units/isq/si/thermal_conductivity.h>
|
||||
#include <units/isq/si/thermodynamic_temperature.h>
|
||||
#include <units/isq/si/time.h>
|
||||
#include <units/isq/si/torque.h>
|
||||
#include <units/isq/si/voltage.h>
|
||||
#include <units/isq/si/volume.h>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
// TODO Add when downcasting issue is solved (collides with pressure)
|
||||
// #include <units/isq/si/energy_density.h>
|
||||
|
||||
// TODO Add when downcasting issue is solved (collides with frequency)
|
||||
// #include <units/isq/si/radioactivity.h>
|
||||
|
@@ -318,7 +318,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
const auto q = 2_q_s * 2_q_m * 2_q_kg;
|
||||
os << q;
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 m ⋅ kg ⋅ s"); }
|
||||
SECTION("iostream") { CHECK(os.str() == "8 m⋅kg⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
@@ -330,7 +330,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
const auto q = 2._q_s * si::cgs::length<si::cgs::centimetre>(2) * si::cgs::mass<si::cgs::gram>(2);
|
||||
os << q;
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 cm ⋅ g ⋅ s"); }
|
||||
SECTION("iostream") { CHECK(os.str() == "8 cm⋅g⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
@@ -343,7 +343,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
const auto q = 4_q_km * 2_q_s;
|
||||
os << q;
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 × 10³ m ⋅ s"); }
|
||||
SECTION("iostream") { CHECK(os.str() == "8 × 10³ m⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
@@ -379,7 +379,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
const auto q = 2._q_s * si::cgs::length<si::metre>(2) * si::cgs::mass<si::kilogram>(2);
|
||||
os << q;
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 × 10⁵ cm ⋅ g ⋅ s"); }
|
||||
SECTION("iostream") { CHECK(os.str() == "8 × 10⁵ cm⋅g⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
@@ -404,7 +404,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
const auto q = 4_q_m * 2_q_s;
|
||||
os << q;
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 m ⋅ s"); }
|
||||
SECTION("iostream") { CHECK(os.str() == "8 m⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
@@ -416,7 +416,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
const auto q = 4_q_m * 2_q_s * 2_q_s;
|
||||
os << q;
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "16 m ⋅ s²"); }
|
||||
SECTION("iostream") { CHECK(os.str() == "16 m⋅s²"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
@@ -428,7 +428,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
const auto q = 8_q_s / 2_q_m / 2_q_m;
|
||||
os << q;
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "2 1/m² ⋅ s"); }
|
||||
SECTION("iostream") { CHECK(os.str() == "2 1/m²⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
|
@@ -167,7 +167,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]")
|
||||
|
||||
SECTION("momentum")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_kg_m_per_s) == "1 kg ⋅ m/s");
|
||||
CHECK(STD_FMT::format("{}", 1_q_kg_m_per_s) == "1 kg⋅m/s");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_kg_m_per_s) == "1 kg m/s");
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]")
|
||||
|
||||
SECTION("dynamic viscosity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_Pa_s) == "1 Pa ⋅ s");
|
||||
CHECK(STD_FMT::format("{}", 1_q_Pa_s) == "1 Pa⋅s");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_Pa_s) == "1 Pa s");
|
||||
}
|
||||
|
||||
@@ -252,19 +252,19 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]")
|
||||
|
||||
SECTION("specific heat capacity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_J_per_kg_K) == "1 J ⋅ K⁻¹ ⋅ kg⁻¹");
|
||||
CHECK(STD_FMT::format("{}", 1_q_J_per_kg_K) == "1 J⋅K⁻¹⋅kg⁻¹");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_J_per_kg_K) == "1 J K^-1 kg^-1");
|
||||
}
|
||||
|
||||
SECTION("molar heath capacity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_J_per_mol_K) == "1 J ⋅ K⁻¹ ⋅ mol⁻¹");
|
||||
CHECK(STD_FMT::format("{}", 1_q_J_per_mol_K) == "1 J⋅K⁻¹⋅mol⁻¹");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_J_per_mol_K) == "1 J K^-1 mol^-1");
|
||||
}
|
||||
|
||||
SECTION("thermal conductivity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_W_per_m_K) == "1 W ⋅ m⁻¹ ⋅ K⁻¹");
|
||||
CHECK(STD_FMT::format("{}", 1_q_W_per_m_K) == "1 W⋅m⁻¹⋅K⁻¹");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_W_per_m_K) == "1 W m^-1 K^-1");
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]")
|
||||
|
||||
SECTION("molar energy") { CHECK(STD_FMT::format("{}", 1_q_J_per_mol) == "1 J/mol"); }
|
||||
|
||||
SECTION("torque") { CHECK(STD_FMT::format("{}", 1_q_N_m_per_rad) == "1 N ⋅ m/rad"); }
|
||||
SECTION("torque") { CHECK(STD_FMT::format("{}", 1_q_N_m_per_rad) == "1 N⋅m/rad"); }
|
||||
|
||||
SECTION("storage_capacity")
|
||||
{
|
||||
|
@@ -88,8 +88,8 @@ static_assert(10_q_pdl * 10_q_ft == 100_q_ft_pdl);
|
||||
static_assert(100_q_ft_pdl / 10_q_ft == 10_q_pdl);
|
||||
static_assert(100_q_ft_pdl / 10_q_pdl == 10_q_ft);
|
||||
|
||||
static_assert(detail::unit_text<dim_energy, foot_poundal>() == basic_symbol_text("ft ⋅ pdl", "ft pdl"));
|
||||
static_assert(detail::unit_text<dim_energy, foot_pound_force>() == basic_symbol_text("ft ⋅ lbf", "ft lbf"));
|
||||
static_assert(detail::unit_text<dim_energy, foot_poundal>() == basic_symbol_text("ft⋅pdl", "ft pdl"));
|
||||
static_assert(detail::unit_text<dim_energy, foot_pound_force>() == basic_symbol_text("ft⋅lbf", "ft lbf"));
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF OTHER UNITS **************** */
|
||||
|
||||
@@ -99,8 +99,8 @@ static_assert(10_q_ft_pdl / 10_q_s == 1_q_ft_pdl_per_s);
|
||||
static_assert(1_q_ft_pdl_per_s * 10_q_s == 10_q_ft_pdl);
|
||||
static_assert(10_q_ft_pdl / 1_q_ft_pdl_per_s == 10_q_s);
|
||||
|
||||
static_assert(detail::unit_text<dim_power, foot_poundal_per_second>() == basic_symbol_text("ft ⋅ pdl/s", "ft pdl/s"));
|
||||
static_assert(detail::unit_text<dim_power, foot_poundal_per_second>() == basic_symbol_text("ft⋅pdl/s", "ft pdl/s"));
|
||||
static_assert(detail::unit_text<dim_power, foot_pound_force_per_second>() ==
|
||||
basic_symbol_text("ft ⋅ lbf/s", "ft lbf/s"));
|
||||
basic_symbol_text("ft⋅lbf/s", "ft lbf/s"));
|
||||
|
||||
} // namespace
|
||||
|
@@ -288,8 +288,10 @@ static_assert(get_length_derived_quantity() == 1_q_m);
|
||||
/////////
|
||||
|
||||
#if UNITS_COMP_GCC >= 11 || UNITS_COMP_CLANG > 15
|
||||
static_assert(std::is_same_v<decltype(units::aliases::isq::si::m(123))::rep, int>);
|
||||
static_assert(std::is_same_v<decltype(units::aliases::isq::si::m(123.))::rep, double>);
|
||||
static_assert(std::is_same_v<decltype(aliases::isq::si::m(123))::rep, int>);
|
||||
static_assert(std::is_same_v<decltype(aliases::isq::si::m(123.))::rep, double>);
|
||||
static_assert(
|
||||
std::is_same_v<decltype(aliases::isq::si::m3(aliases::isq::si::m2{2} * aliases::isq::si::m{3}))::rep, int>);
|
||||
#endif
|
||||
|
||||
static_assert(is_same_v<decltype(quantity{length<metre, int>(123)}), length<metre, int>>);
|
||||
|
@@ -239,6 +239,12 @@ static_assert(gray::symbol == "Gy");
|
||||
static_assert(milligray::symbol == "mGy");
|
||||
static_assert(kilogray::symbol == "kGy");
|
||||
|
||||
// luminous flux
|
||||
|
||||
static_assert(683_q_lm == 1_q_W);
|
||||
|
||||
static_assert(lumen::symbol == "lm");
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */
|
||||
|
||||
// speed
|
||||
@@ -334,7 +340,7 @@ static_assert(detail::unit_text<dim_luminance, candela_per_metre_sq>() == basic_
|
||||
// dynamic viscosity
|
||||
|
||||
static_assert(1_q_Pa_s == 1_q_N * 1_q_s / 1_q_m2);
|
||||
static_assert(detail::unit_text<dim_dynamic_viscosity, pascal_second>() == basic_symbol_text("Pa ⋅ s", "Pa s"));
|
||||
static_assert(detail::unit_text<dim_dynamic_viscosity, pascal_second>() == basic_symbol_text("Pa⋅s", "Pa s"));
|
||||
|
||||
// [specific|molar] heath capacity
|
||||
|
||||
@@ -344,13 +350,13 @@ static_assert(1_q_J_per_mol_K == 1_q_J_per_K / 1_q_mol);
|
||||
|
||||
static_assert(detail::unit_text<dim_heat_capacity, joule_per_kelvin>() == "J/K");
|
||||
static_assert(detail::unit_text<dim_specific_heat_capacity, joule_per_kilogram_kelvin>() ==
|
||||
basic_symbol_text("J ⋅ K⁻¹ ⋅ kg⁻¹", "J K^-1 kg^-1"));
|
||||
basic_symbol_text("J⋅K⁻¹⋅kg⁻¹", "J K^-1 kg^-1"));
|
||||
|
||||
// thermal conductivity
|
||||
|
||||
static_assert(20_q_W_per_m_K * 10_q_m * 300_q_K == 60'000_q_W);
|
||||
static_assert(detail::unit_text<dim_thermal_conductivity, watt_per_metre_kelvin>() ==
|
||||
basic_symbol_text("W ⋅ m⁻¹ ⋅ K⁻¹", "W m^-1 K^-1"));
|
||||
basic_symbol_text("W⋅m⁻¹⋅K⁻¹", "W m^-1 K^-1"));
|
||||
|
||||
// electric field strength
|
||||
|
||||
|
@@ -21,8 +21,8 @@
|
||||
# SOFTWARE.
|
||||
|
||||
from conan import ConanFile
|
||||
from conan.tools.cmake import CMake
|
||||
from conan.tools.build import cross_building
|
||||
from conan.tools.cmake import CMake
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
|
Reference in New Issue
Block a user