mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 02:17:16 +02:00
feat: isq::activity
added and becquerel
definition updated to benefit from it
This commit is contained in:
@ -25,7 +25,11 @@ cmake_minimum_required(VERSION 3.19)
|
||||
add_units_module(
|
||||
isq
|
||||
DEPENDENCIES mp-units::core
|
||||
HEADERS include/mp-units/systems/isq/base_quantities.h include/mp-units/systems/isq/electromagnetism.h
|
||||
include/mp-units/systems/isq/isq.h include/mp-units/systems/isq/mechanics.h
|
||||
include/mp-units/systems/isq/space_and_time.h include/mp-units/systems/isq/thermodynamics.h
|
||||
HEADERS include/mp-units/systems/isq/atomic_and_nuclear_physics.h
|
||||
include/mp-units/systems/isq/base_quantities.h
|
||||
include/mp-units/systems/isq/electromagnetism.h
|
||||
include/mp-units/systems/isq/isq.h
|
||||
include/mp-units/systems/isq/mechanics.h
|
||||
include/mp-units/systems/isq/space_and_time.h
|
||||
include/mp-units/systems/isq/thermodynamics.h
|
||||
)
|
||||
|
@ -0,0 +1,34 @@
|
||||
// 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 <mp-units/quantity_spec.h>
|
||||
#include <mp-units/systems/isq/base_quantities.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
|
||||
namespace mp_units::isq {
|
||||
|
||||
// TODO Add all the remaining ISQ definitions
|
||||
QUANTITY_SPEC(activity, 1 / duration);
|
||||
|
||||
} // namespace mp_units::isq
|
@ -23,6 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <mp-units/systems/isq/atomic_and_nuclear_physics.h>
|
||||
#include <mp-units/systems/isq/base_quantities.h>
|
||||
#include <mp-units/systems/isq/electromagnetism.h>
|
||||
#include <mp-units/systems/isq/mechanics.h>
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/systems/isq/atomic_and_nuclear_physics.h>
|
||||
#include <mp-units/systems/isq/base_quantities.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/prefixes.h>
|
||||
@ -73,7 +74,7 @@ inline constexpr struct lumen : named_unit<"lm", candela * steradian> {} lumen;
|
||||
inline constexpr struct lux : named_unit<"lx", lumen / square(metre)> {} lux;
|
||||
// TODO add when isq::activity will be supported
|
||||
// inline constexpr struct becquerel : named_unit<"Bq", 1 / second, kind_of<isq::activity>> {} becquerel;
|
||||
inline constexpr struct becquerel : named_unit<"Bq", 1 / second> {} becquerel;
|
||||
inline constexpr struct becquerel : named_unit<"Bq", 1 / second, kind_of<isq::activity>> {} becquerel;
|
||||
inline constexpr struct gray : named_unit<"Gy", joule / kilogram> {} gray;
|
||||
inline constexpr struct sievert : named_unit<"Sv", joule / kilogram> {} sievert;
|
||||
inline constexpr struct katal : named_unit<"kat", mole / second> {} katal;
|
||||
|
@ -55,7 +55,6 @@ inline constexpr struct zero : absolute_point_origin<dimensionless> {
|
||||
} zero;
|
||||
|
||||
QUANTITY_SPEC(special_height, isq::height);
|
||||
QUANTITY_SPEC(activity, 1 / isq::time);
|
||||
|
||||
/////////////////////
|
||||
// class invariants
|
||||
@ -1203,18 +1202,18 @@ consteval bool invalid_subtraction(Ts... ts)
|
||||
return !requires { (... - ts); };
|
||||
}
|
||||
|
||||
inline constexpr struct zero_Bq : absolute_point_origin<kind_of<activity>> {
|
||||
inline constexpr struct zero_Bq : absolute_point_origin<kind_of<isq::activity>> {
|
||||
} zero_Bq;
|
||||
|
||||
static_assert(invalid_addition(zero_Bq + 5 * activity[Bq], 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_addition(5 * activity[Bq], zero_Hz + 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_subtraction(zero_Bq + 5 * activity[Bq], 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_subtraction(zero_Bq + 5 * activity[Bq], zero_Hz + 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_addition(zero_Bq + 5 * isq::activity[Bq], 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_addition(5 * isq::activity[Bq], zero_Hz + 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_subtraction(zero_Bq + 5 * isq::activity[Bq], 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_subtraction(zero_Bq + 5 * isq::activity[Bq], zero_Hz + 5 * isq::frequency[Hz]));
|
||||
|
||||
static_assert(invalid_addition(zero_Bq + 5 * activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_addition(5 * activity[Bq], zero_Hz + 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_addition(5 * activity[Bq], 10 / (2 * isq::time[s]), zero_Hz + 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_subtraction(zero_Bq + 5 * activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_addition(zero_Bq + 5 * isq::activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_addition(5 * isq::activity[Bq], zero_Hz + 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_addition(5 * isq::activity[Bq], 10 / (2 * isq::time[s]), zero_Hz + 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_subtraction(zero_Bq + 5 * isq::activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
|
||||
|
||||
|
||||
/////////////////////////
|
||||
|
@ -36,8 +36,6 @@ namespace {
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
QUANTITY_SPEC(activity, 1 / isq::time);
|
||||
|
||||
//////////////////////////////
|
||||
// quantity class invariants
|
||||
//////////////////////////////
|
||||
@ -695,8 +693,8 @@ consteval bool invalid_arithmetic(Ts... ts)
|
||||
{
|
||||
return !requires { (... + ts); } && !requires { (... - ts); };
|
||||
}
|
||||
static_assert(invalid_arithmetic(5 * activity[Bq], 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_arithmetic(5 * activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_arithmetic(5 * isq::activity[Bq], 5 * isq::frequency[Hz]));
|
||||
static_assert(invalid_arithmetic(5 * isq::activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
|
||||
|
||||
// Physical constants
|
||||
static_assert(1 * si::si2019::speed_of_light_in_vacuum + 10 * isq::speed[m / s] == 299'792'468 * isq::speed[m / s]);
|
||||
@ -817,7 +815,7 @@ static_assert(1 * si::si2019::speed_of_light_in_vacuum == 299'792'458 * isq::spe
|
||||
// Different named dimensions
|
||||
template</*Reference*/ auto R1, /*Reference*/ auto R2> // TODO Use `Reference` when Clang supports it.
|
||||
concept invalid_comparison = !requires { 2 * R1 == 2 * R2; } && !requires { 2 * R2 == 2 * R1; };
|
||||
static_assert(invalid_comparison<activity[Bq], isq::frequency[Hz]>);
|
||||
static_assert(invalid_comparison<isq::activity[Bq], isq::frequency[Hz]>);
|
||||
|
||||
|
||||
///////////////////////
|
||||
|
Reference in New Issue
Block a user