Merge branch 'master' into chiphogg/switch-to-mag

This commit is contained in:
Chip Hogg
2022-06-15 20:50:30 +00:00
30 changed files with 391 additions and 116 deletions
+1
View File
@@ -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)
+5 -5
View File
@@ -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
View 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<>);
}