diff --git a/src/include/units/physical/dimensions.h b/src/include/units/physical/dimensions.h index c7e44ca0..13c53b67 100644 --- a/src/include/units/physical/dimensions.h +++ b/src/include/units/physical/dimensions.h @@ -39,7 +39,7 @@ #include #include #include -// TODO Add when downcasting issue is solved +// TODO Add when downcasting issue is solved (collides with pressure) // #include #include #include @@ -57,7 +57,7 @@ #include #include #include -// TODO Add when downcasting issue is solved +// TODO Add when downcasting issue is solved (collides with frequency) // #include #include #include diff --git a/src/include/units/physical/dimensions/energy_density.h b/src/include/units/physical/dimensions/energy_density.h index c46dcad7..44ba8722 100644 --- a/src/include/units/physical/dimensions/energy_density.h +++ b/src/include/units/physical/dimensions/energy_density.h @@ -24,15 +24,14 @@ #include #include -#include +#include namespace units::physical { -// TODO Add when downcasting issue is solved -// template E, DimensionOfT L> -// struct dim_energy_density : derived_dimension, exponent> {}; +template E, DimensionOfT V> +struct dim_energy_density : derived_dimension, exponent> {}; -// template -// concept EnergyDensity = QuantityOfT; +template +concept EnergyDensity = QuantityOfT; } // namespace units::physical diff --git a/src/include/units/physical/dimensions/radioactivity.h b/src/include/units/physical/dimensions/radioactivity.h index b82e94a1..3caa1c3a 100644 --- a/src/include/units/physical/dimensions/radioactivity.h +++ b/src/include/units/physical/dimensions/radioactivity.h @@ -27,11 +27,10 @@ namespace units::physical { -// TODO Add when downcasting issue is solved -// template T> -// struct dim_radioactivity : derived_dimension> {}; +template T> +struct dim_radioactivity : derived_dimension> {}; -// template -// concept Radioactivity = QuantityOfT; +template +concept Radioactivity = QuantityOfT; } // namespace units::physical diff --git a/src/include/units/physical/si/derived/energy_density.h b/src/include/units/physical/si/derived/energy_density.h new file mode 100644 index 00000000..1f1d2ecd --- /dev/null +++ b/src/include/units/physical/si/derived/energy_density.h @@ -0,0 +1,46 @@ +// 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 +#include +#include +#include + +namespace units::physical::si { + +struct joule_per_metre_cub : unit {}; +struct dim_energy_density : physical::dim_energy_density {}; + +template U, QuantityValue Rep = double> +using energy_density = quantity; + +inline namespace literals { + +// N/m +constexpr auto operator"" _q_J_per_m3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy_density(static_cast(l)); } +constexpr auto operator"" _q_J_per_m3(long double l) { return energy_density(l); } + +} // namespace literals + +} // namespace units::physical::si diff --git a/src/include/units/physical/si/derived/radioactivity.h b/src/include/units/physical/si/derived/radioactivity.h new file mode 100644 index 00000000..78d632f3 --- /dev/null +++ b/src/include/units/physical/si/derived/radioactivity.h @@ -0,0 +1,172 @@ +// 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 +#include +#include + +namespace units::physical::si { + +struct becquerel : named_unit {}; +struct yoctobecquerel : prefixed_unit {}; +struct zeptobecquerel : prefixed_unit {}; +struct attobecquerel : prefixed_unit {}; +struct femtobecquerel : prefixed_unit {}; +struct picobecquerel : prefixed_unit {}; +struct nanobecquerel : prefixed_unit {}; +struct microbecquerel : prefixed_unit {}; +struct millibecquerel : prefixed_unit {}; +struct centibecquerel : prefixed_unit {}; +struct decibecquerel : prefixed_unit {}; +struct decabecquerel : prefixed_unit {}; +struct hectobecquerel : prefixed_unit {}; +struct kilobecquerel : prefixed_unit {}; +struct megabecquerel : prefixed_unit {}; +struct gigabecquerel : prefixed_unit {}; +struct terabecquerel : prefixed_unit {}; +struct petabecquerel : prefixed_unit {}; +struct exabecquerel : prefixed_unit {}; +struct zettabecquerel : prefixed_unit {}; +struct yottabecquerel : prefixed_unit {}; + +struct dim_radioactivity : physical::dim_radioactivity {}; + +template U, QuantityValue Rep = double> +using radioactivity = quantity; + +inline namespace literals { + +// Bq +constexpr auto operator"" _q_Bq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_Bq(long double l) { return radioactivity(l); } + +// yBq +constexpr auto operator"" _q_yBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_yBq(long double l) { return radioactivity(l); } + +// zBq +constexpr auto operator"" _q_zBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_zBq(long double l) { return radioactivity(l); } + +// aBq +constexpr auto operator"" _q_aBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_aBq(long double l) { return radioactivity(l); } + +// fBq +constexpr auto operator"" _q_fBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_fBq(long double l) { return radioactivity(l); } + +// pBq +constexpr auto operator"" _q_pBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_pBq(long double l) { return radioactivity(l); } + +// nBq +constexpr auto operator"" _q_nBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_nBq(long double l) { return radioactivity(l); } + +// uBq +constexpr auto operator"" _q_uBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_uBq(long double l) { return radioactivity(l); } + +// mBq +constexpr auto operator"" _q_mBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_mBq(long double l) { return radioactivity(l); } + +// cBq +constexpr auto operator"" _q_cBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_cBq(long double l) { return radioactivity(l); } + +// dBq +constexpr auto operator"" _q_dBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_dBq(long double l) { return radioactivity(l); } + +// daBq +constexpr auto operator"" _q_daBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_daBq(long double l) { return radioactivity(l); } + +// hBq +constexpr auto operator"" _q_hBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_hBq(long double l) { return radioactivity(l); } + +// kBq +constexpr auto operator"" _q_kBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_kBq(long double l) { return radioactivity(l); } + +// MBq +constexpr auto operator"" _q_MBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_MBq(long double l) { return radioactivity(l); } + +// GBq +constexpr auto operator"" _q_GBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_GBq(long double l) { return radioactivity(l); } + +// TBq +constexpr auto operator"" _q_TBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_TBq(long double l) { return radioactivity(l); } + +// PBq +constexpr auto operator"" _q_PBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_PBq(long double l) { return radioactivity(l); } + +// EBq +constexpr auto operator"" _q_EBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_EBq(long double l) { return radioactivity(l); } + +// ZBq +constexpr auto operator"" _q_ZBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_ZBq(long double l) { return radioactivity(l); } + +// YBq +constexpr auto operator"" _q_YBq(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return radioactivity(static_cast(l)); } +constexpr auto operator"" _q_YBq(long double l) { return radioactivity(l); } + +} // namespace literals + +namespace unit_constants { + +inline constexpr auto Bq = radioactivity{}; +inline constexpr auto yBq = radioactivity{}; +inline constexpr auto zBq = radioactivity{}; +inline constexpr auto aBq = radioactivity{}; +inline constexpr auto fBq = radioactivity{}; +inline constexpr auto pBq = radioactivity{}; +inline constexpr auto nBq = radioactivity{}; +inline constexpr auto uBq = radioactivity{}; +inline constexpr auto mBq = radioactivity{}; +inline constexpr auto cBq = radioactivity{}; +inline constexpr auto dBq = radioactivity{}; +inline constexpr auto daBq = radioactivity{}; +inline constexpr auto hBq = radioactivity{}; +inline constexpr auto kBq = radioactivity{}; +inline constexpr auto MBq = radioactivity{}; +inline constexpr auto GBq = radioactivity{}; +inline constexpr auto TBq = radioactivity{}; +inline constexpr auto PBq = radioactivity{}; +inline constexpr auto EBq = radioactivity{}; +inline constexpr auto ZBq = radioactivity{}; +inline constexpr auto YBq = radioactivity{}; + +} // namespace unit_constants + +} // namespace units::physical::si diff --git a/src/include/units/physical/si/si.h b/src/include/units/physical/si/si.h index b0839d8b..e398955d 100644 --- a/src/include/units/physical/si/si.h +++ b/src/include/units/physical/si/si.h @@ -45,6 +45,8 @@ #include #include #include +// TODO Add when downcasting issue is solved (collides with pressure) +// #include #include #include #include @@ -58,6 +60,8 @@ #include #include #include +// TODO Add when downcasting issue is solved (collides with frequency) +// #include #include #include #include diff --git a/test/unit_test/static/dimensions_concepts_test.cpp b/test/unit_test/static/dimensions_concepts_test.cpp index 29e4bc1a..247df14e 100644 --- a/test/unit_test/static/dimensions_concepts_test.cpp +++ b/test/unit_test/static/dimensions_concepts_test.cpp @@ -113,7 +113,7 @@ static_assert(Conductance>); static_assert(!Conductance>); // TODO Add when downcasting issue is solved -// static_assert(Radioactivity>); +// static_assert(Radioactivity>); // static_assert(!Radioactivity>); static_assert(CatalyticActivity>);