// 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 "test_tools.h" #include #include #include #include namespace { using namespace units; using dimensionless_ = struct dimensionless; using dim_one_ = struct dimension_one; // clang-format off inline constexpr struct dim_length_ : base_dimension<"L"> {} dim_length; inline constexpr struct dim_mass_ : base_dimension<"M"> {} dim_mass; inline constexpr struct dim_time_ : base_dimension<"T"> {} dim_time; // quantities specification QUANTITY_SPEC_(length, dim_length); QUANTITY_SPEC_(mass, dim_mass); QUANTITY_SPEC_(time, dim_time); inline constexpr struct second_ : named_unit<"s", time> {} second; QUANTITY_SPEC_(height, length); QUANTITY_SPEC_(path_length, length); QUANTITY_SPEC_(distance, path_length); QUANTITY_SPEC_(position_vector, length, quantity_character::vector); QUANTITY_SPEC_(period_duration, time); QUANTITY_SPEC_(frequency, 1 / period_duration); QUANTITY_SPEC_(action, 1 / time); QUANTITY_SPEC_(area, pow<2>(length)); QUANTITY_SPEC_(volume, pow<3>(length)); QUANTITY_SPEC_(velocity, position_vector / time); QUANTITY_SPEC_(speed, distance / time); QUANTITY_SPEC_(acceleration, velocity / time); QUANTITY_SPEC_(force, mass * acceleration); QUANTITY_SPEC_(moment_of_force, position_vector* force); QUANTITY_SPEC_(torque, moment_of_force, quantity_character::scalar); QUANTITY_SPEC_(pressure, force / area, quantity_character::scalar); QUANTITY_SPEC_(stress, pressure, quantity_character::tensor); QUANTITY_SPEC_(strain, dimensionless, quantity_character::tensor); QUANTITY_SPEC_(power, force* velocity, quantity_character::scalar); QUANTITY_SPEC_(efficiency, power / power); QUANTITY_SPEC_(potential_energy, mass* acceleration* height); QUANTITY_SPEC_(energy, force * length); // clang-format on // concepts verification static_assert(QuantitySpec); static_assert(BaseQuantitySpec); static_assert(NamedQuantitySpec); static_assert(!DerivedQuantitySpec); static_assert(QuantitySpec); static_assert(!BaseQuantitySpec); static_assert(NamedQuantitySpec); static_assert(!DerivedQuantitySpec); static_assert(QuantitySpec); static_assert(!BaseQuantitySpec); static_assert(!NamedQuantitySpec); static_assert(DerivedQuantitySpec); static_assert(QuantitySpec); static_assert(!BaseQuantitySpec); static_assert(NamedQuantitySpec); static_assert(!DerivedQuantitySpec); // dimensionless static_assert(QuantitySpec); static_assert(!BaseQuantitySpec); static_assert(NamedQuantitySpec); static_assert(!DerivedQuantitySpec); // length static_assert(QuantitySpec); static_assert(!BaseQuantitySpec); static_assert(!NamedQuantitySpec); static_assert(DerivedQuantitySpec); // derived QuantitySpec expression template syntax verification static_assert(is_of_type<1 / time, derived_quantity_spec>>); static_assert(is_of_type<1 / (1 / time), time_>); static_assert(is_of_type); static_assert(is_of_type