Design cleanup

- unknown_unit added
- examples refactored
- base_type renamed to downcast_base_type
- scaled_unit renamed to named_scaled_unit
- detail::reference_unit renamed to scaled_unit
- quantity_test cleanup
This commit is contained in:
Mateusz Pusz committed 2019-12-06 12:18:39 +01:00
1 parent c48bfe2098
commit f31b26b5e5
22 files changed
+354 -160

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@ template<typename Dim, template<typename...> typename DimTemplate>
concept DimensionOf = (Dimension<Dim> || BaseDimension<Dim>) && is_derived_from_instantiation<Dim, DimTemplate>;
template<typename Q, template<typename...> typename DimTemplate>
concept QuantityOf = Quantity<Q> && is_derived_from_instantiation<Q::dimension, DimTemplate>;
concept QuantityOf = Quantity<Q> && is_derived_from_instantiation<typename Q::dimension, DimTemplate>;
// ------------------------ base dimensions -----------------------------
@@ -0,0 +1,44 @@
// 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/physical/dimensions.h>
#include <units/physical/si/velocity.h>
namespace units::si {
struct metre_per_second_sq : unit<metre_per_second_sq> {};
struct dim_acceleration : physical::dim_acceleration<dim_acceleration, metre_per_second_sq, dim_length, dim_time> {};
template<Unit U, Scalar Rep = double>
using acceleration = quantity<dim_acceleration, U, Rep>;
inline namespace literals {
// mps_sq
constexpr auto operator""mps_sq(unsigned long long l) { return acceleration<metre_per_second_sq, std::int64_t>(l); }
constexpr auto operator""mps_sq(long double l) { return acceleration<metre_per_second_sq, long double>(l); }
} // namespace literals
} // namespace units::si
+4 -4
View File
@@ -58,10 +58,10 @@ constexpr auto operator"" km(long double l) { return length<kilometre, long doub
} // namespace literals
// US customary units
struct yard : scaled_unit<yard, "yd", no_prefix, ratio<9'144, 10'000>, metre> {};
struct foot : scaled_unit<foot, "ft", no_prefix, ratio<1, 3>, yard> {};
struct inch : scaled_unit<inch, "in", no_prefix, ratio<1, 12>, foot> {};
struct mile : scaled_unit<mile, "mi", no_prefix, ratio<1'760>, yard> {};
struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio<9'144, 10'000>, metre> {};
struct foot : named_scaled_unit<foot, "ft", no_prefix, ratio<1, 3>, yard> {};
struct inch : named_scaled_unit<inch, "in", no_prefix, ratio<1, 12>, foot> {};
struct mile : named_scaled_unit<mile, "mi", no_prefix, ratio<1'760>, yard> {};
inline namespace literals {
+2 -2
View File
@@ -31,8 +31,8 @@ struct second : named_unit<second, "s", prefix> {};
struct nanosecond : prefixed_unit<nanosecond, nano, second> {};
struct microsecond : prefixed_unit<microsecond, micro, second> {};
struct millisecond : prefixed_unit<millisecond, milli, second> {};
struct minute : scaled_unit<minute, "min", no_prefix, ratio<60>, second> {};
struct hour : scaled_unit<hour, "h", no_prefix, ratio<3600>, second> {};
struct minute : named_scaled_unit<minute, "min", no_prefix, ratio<60>, second> {};
struct hour : named_scaled_unit<hour, "h", no_prefix, ratio<3600>, second> {};
struct dim_time : physical::dim_time<second> {};