mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 02:17:16 +02:00
Refactored units definitions, added the remaining SI base units, refactored header includes
This commit is contained in:
@ -20,7 +20,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "units/si/velocity.h"
|
||||
#include <units/velocity.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace {
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../dimension.h"
|
||||
#include <units/dimension.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
@ -31,9 +31,9 @@ namespace units {
|
||||
struct base_dim_length : dim_id<0> {};
|
||||
struct base_dim_mass : dim_id<1> {};
|
||||
struct base_dim_time : dim_id<2> {};
|
||||
struct base_dim_electric_current : dim_id<3> {};
|
||||
struct base_dim_current : dim_id<3> {};
|
||||
struct base_dim_temperature : dim_id<4> {};
|
||||
struct base_dim_amount_of_substance : dim_id<5> {};
|
||||
struct base_dim_substance : dim_id<5> {};
|
||||
struct base_dim_luminous_intensity : dim_id<6> {};
|
||||
|
||||
} // namespace units
|
@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "tools.h"
|
||||
#include <units/bits/tools.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mp {
|
||||
|
50
src/include/units/current.h
Normal file
50
src/include/units/current.h
Normal file
@ -0,0 +1,50 @@
|
||||
// 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/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
struct dimension_current : make_dimension_t<exp<base_dim_current, 1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<dimension_current>> : upcast_to<dimension_current> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Current = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_current>;
|
||||
|
||||
template<Unit U = struct ampere, Number Rep = double>
|
||||
using current = quantity<dimension_current, U, Rep>;
|
||||
|
||||
struct ampere : unit<dimension_current, std::ratio<1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<ampere>> : upcast_to<ampere> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// A
|
||||
constexpr auto operator""_A(unsigned long long l) { return current<ampere, std::int64_t>(l); }
|
||||
constexpr auto operator""_A(long double l) { return current<ampere, long double>(l); }
|
||||
|
||||
}
|
||||
|
||||
} // namespace units
|
@ -22,8 +22,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bits/tools.h"
|
||||
#include "bits/type_list.h"
|
||||
#include <units/bits/tools.h>
|
||||
#include <units/bits/type_list.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
|
@ -22,14 +22,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base_dimensions.h"
|
||||
#include "time.h"
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/time.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
struct dimension_frequency : make_dimension_t<exp<base_dim_time, -1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<dimension_frequency>> : upcast_to<dimension_frequency> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Frequency = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_frequency>;
|
||||
|
||||
template<Unit U = struct hertz, Number Rep = double>
|
||||
using frequency = quantity<dimension_frequency, U, Rep>;
|
||||
|
||||
struct millihertz : unit<dimension_frequency, std::milli> {};
|
||||
template<> struct upcasting_traits<upcast_from<millihertz>> : upcast_to<millihertz> {};
|
||||
|
||||
@ -48,12 +54,6 @@ namespace units {
|
||||
struct terahertz : unit<dimension_frequency, std::tera> {};
|
||||
template<> struct upcasting_traits<upcast_from<terahertz>> : upcast_to<terahertz> {};
|
||||
|
||||
template<Unit U = hertz, Number Rep = double>
|
||||
using frequency = quantity<dimension_frequency, U, Rep>;
|
||||
|
||||
template<typename T>
|
||||
concept bool Frequency = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_frequency>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// mHz
|
@ -22,15 +22,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base_dimensions.h"
|
||||
#include "../quantity.h"
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
// dimension
|
||||
struct dimension_length : make_dimension_t<exp<base_dim_length, 1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<dimension_length>> : upcast_to<dimension_length> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Length = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_length>;
|
||||
|
||||
template<Unit U = struct meter, Number Rep = double>
|
||||
using length = quantity<dimension_length, U, Rep>;
|
||||
|
||||
// SI units
|
||||
struct millimeter : unit<dimension_length, std::milli> {};
|
||||
template<> struct upcasting_traits<upcast_from<millimeter>> : upcast_to<millimeter> {};
|
||||
@ -44,26 +49,6 @@ namespace units {
|
||||
struct kilometer : unit<dimension_length, std::kilo> {};
|
||||
template<> struct upcasting_traits<upcast_from<kilometer>> : upcast_to<kilometer> {};
|
||||
|
||||
// US customary units
|
||||
struct yard : unit<dimension_length, std::ratio<9'144, 10'000>> {};
|
||||
template<> struct upcasting_traits<upcast_from<yard>> : upcast_to<yard> {};
|
||||
|
||||
struct foot : unit<dimension_length, std::ratio_multiply<std::ratio<1, 3>, yard::ratio>> {};
|
||||
template<> struct upcasting_traits<upcast_from<foot>> : upcast_to<foot> {};
|
||||
|
||||
struct inch : unit<dimension_length, std::ratio_multiply<std::ratio<1, 12>, foot::ratio>> {};
|
||||
template<> struct upcasting_traits<upcast_from<inch>> : upcast_to<inch> {};
|
||||
|
||||
struct mile : unit<dimension_length, std::ratio_multiply<std::ratio<1'760>, yard::ratio>> {};
|
||||
template<> struct upcasting_traits<upcast_from<mile>> : upcast_to<mile> {};
|
||||
|
||||
// length
|
||||
template<Unit U = meter, Number Rep = double>
|
||||
using length = quantity<dimension_length, U, Rep>;
|
||||
|
||||
template<typename T>
|
||||
concept bool Length = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_length>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// mm
|
||||
@ -82,6 +67,23 @@ namespace units {
|
||||
constexpr auto operator""_km(unsigned long long l) { return length<kilometer, std::int64_t>(l); }
|
||||
constexpr auto operator""_km(long double l) { return length<kilometer, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
// US customary units
|
||||
struct yard : unit<dimension_length, std::ratio<9'144, 10'000>> {};
|
||||
template<> struct upcasting_traits<upcast_from<yard>> : upcast_to<yard> {};
|
||||
|
||||
struct foot : unit<dimension_length, std::ratio_multiply<std::ratio<1, 3>, yard::ratio>> {};
|
||||
template<> struct upcasting_traits<upcast_from<foot>> : upcast_to<foot> {};
|
||||
|
||||
struct inch : unit<dimension_length, std::ratio_multiply<std::ratio<1, 12>, foot::ratio>> {};
|
||||
template<> struct upcasting_traits<upcast_from<inch>> : upcast_to<inch> {};
|
||||
|
||||
struct mile : unit<dimension_length, std::ratio_multiply<std::ratio<1'760>, yard::ratio>> {};
|
||||
template<> struct upcasting_traits<upcast_from<mile>> : upcast_to<mile> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// yd
|
||||
constexpr auto operator""_yd(unsigned long long l) { return length<yard, std::int64_t>(l); }
|
||||
constexpr auto operator""_yd(long double l) { return length<yard, long double>(l); }
|
50
src/include/units/luminous_intensity.h
Normal file
50
src/include/units/luminous_intensity.h
Normal file
@ -0,0 +1,50 @@
|
||||
// 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/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
struct dimension_luminous_intensity : make_dimension_t<exp<base_dim_luminous_intensity, 1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<dimension_luminous_intensity>> : upcast_to<dimension_luminous_intensity> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool LuminousIntensity = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_luminous_intensity>;
|
||||
|
||||
template<Unit U = struct candela, Number Rep = double>
|
||||
using luminous_intensity = quantity<dimension_luminous_intensity, U, Rep>;
|
||||
|
||||
struct candela : unit<dimension_luminous_intensity, std::ratio<1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<candela>> : upcast_to<candela> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// cd
|
||||
constexpr auto operator""_cd(unsigned long long l) { return luminous_intensity<candela, std::int64_t>(l); }
|
||||
constexpr auto operator""_cd(long double l) { return luminous_intensity<candela, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
53
src/include/units/mass.h
Normal file
53
src/include/units/mass.h
Normal file
@ -0,0 +1,53 @@
|
||||
// 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/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
struct dimension_mass : make_dimension_t<exp<base_dim_mass, 1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<dimension_mass>> : upcast_to<dimension_mass> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Mass = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_mass>;
|
||||
|
||||
template<Unit U = class kilogram, Number Rep = double>
|
||||
using mass = quantity<dimension_mass, U, Rep>;
|
||||
|
||||
struct gram : unit<dimension_mass, std::milli> {};
|
||||
template<> struct upcasting_traits<upcast_from<gram>> : upcast_to<gram> {};
|
||||
|
||||
struct kilogram : unit<dimension_mass, std::ratio<1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<kilogram>> : upcast_to<kilogram> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// kg
|
||||
constexpr auto operator""_kg(unsigned long long l) { return mass<kilogram, std::int64_t>(l); }
|
||||
constexpr auto operator""_kg(long double l) { return mass<kilogram, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "unit.h"
|
||||
#include <units/unit.h>
|
||||
#include <limits>
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
|
50
src/include/units/substance.h
Normal file
50
src/include/units/substance.h
Normal file
@ -0,0 +1,50 @@
|
||||
// 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/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
struct dimension_substance : make_dimension_t<exp<base_dim_substance, 1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<dimension_substance>> : upcast_to<dimension_substance> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Substance = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_substance>;
|
||||
|
||||
template<Unit U = struct mole, Number Rep = double>
|
||||
using substance = quantity<dimension_substance, U, Rep>;
|
||||
|
||||
struct mole : unit<dimension_substance, std::ratio<1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<mole>> : upcast_to<mole> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// mol
|
||||
constexpr auto operator""_mol(unsigned long long l) { return substance<mole, std::int64_t>(l); }
|
||||
constexpr auto operator""_mol(long double l) { return substance<mole, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
50
src/include/units/temperature.h
Normal file
50
src/include/units/temperature.h
Normal file
@ -0,0 +1,50 @@
|
||||
// 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/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
struct dimension_temperature : make_dimension_t<exp<base_dim_temperature, 1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<dimension_temperature>> : upcast_to<dimension_temperature> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool ThermodynamicTemperature = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_temperature>;
|
||||
|
||||
template<Unit U = struct kelvin, Number Rep = double>
|
||||
using temperature = quantity<dimension_temperature, U, Rep>;
|
||||
|
||||
struct kelvin : unit<dimension_temperature, std::ratio<1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<kelvin>> : upcast_to<kelvin> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// K
|
||||
constexpr auto operator""_K(unsigned long long l) { return temperature<kelvin, std::int64_t>(l); }
|
||||
constexpr auto operator""_K(long double l) { return temperature<kelvin, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
@ -22,14 +22,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base_dimensions.h"
|
||||
#include "../quantity.h"
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
struct dimension_time : make_dimension_t<exp<base_dim_time, 1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<dimension_time>> : upcast_to<dimension_time> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Time = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_time>;
|
||||
|
||||
template<Unit U = struct second, Number Rep = double>
|
||||
using time = quantity<dimension_time, U, Rep>;
|
||||
|
||||
struct nanosecond : unit<dimension_time, std::nano> {};
|
||||
template<> struct upcasting_traits<upcast_from<nanosecond>> : upcast_to<nanosecond> {};
|
||||
|
||||
@ -48,13 +54,6 @@ namespace units {
|
||||
struct hour : unit<dimension_time, std::ratio<3600>> {};
|
||||
template<> struct upcasting_traits<upcast_from<hour>> : upcast_to<hour> {};
|
||||
|
||||
template<Unit U = second, Number Rep = double>
|
||||
using time = quantity<dimension_time, U, Rep>;
|
||||
|
||||
|
||||
template<typename T>
|
||||
concept bool Time = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_time>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// ns
|
@ -22,8 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bits/tools.h"
|
||||
#include "dimension.h"
|
||||
#include <units/dimension.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
|
@ -22,15 +22,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base_dimensions.h"
|
||||
#include "length.h"
|
||||
#include "time.h"
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/length.h>
|
||||
#include <units/time.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
struct dimension_velocity : make_dimension_t<exp<base_dim_length, 1>, exp<base_dim_time, -1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<dimension_velocity>> : upcast_to<dimension_velocity> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Velocity = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_velocity>;
|
||||
|
||||
template<Unit U = struct meter_per_second, Number Rep = double>
|
||||
using velocity = quantity<dimension_velocity, U, Rep>;
|
||||
|
||||
struct meter_per_second : unit<dimension_velocity, std::ratio<1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<meter_per_second>> : upcast_to<meter_per_second> {};
|
||||
|
||||
@ -40,12 +46,6 @@ namespace units {
|
||||
struct mile_per_hour : unit<dimension_velocity, std::ratio_divide<mile::ratio, hour::ratio>> {};
|
||||
template<> struct upcasting_traits<upcast_from<mile_per_hour>> : upcast_to<mile_per_hour> {};
|
||||
|
||||
template<Unit U = meter_per_second, Number Rep = double>
|
||||
using velocity = quantity<dimension_velocity, U, Rep>;
|
||||
|
||||
template<typename T>
|
||||
concept bool Velocity = Quantity<T> && std::experimental::ranges::Same<typename T::dimension, dimension_velocity>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// mps
|
@ -20,8 +20,8 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "units/si/velocity.h"
|
||||
#include "units/si/frequency.h"
|
||||
#include "units/velocity.h"
|
||||
#include "units/frequency.h"
|
||||
#include <utility>
|
||||
#include <chrono>
|
||||
|
||||
|
@ -20,10 +20,18 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "units/si/frequency.h"
|
||||
#include "units/si/length.h"
|
||||
#include "units/si/time.h"
|
||||
#include "units/si/velocity.h"
|
||||
#include <units/time.h>
|
||||
#include <units/length.h>
|
||||
#include <units/mass.h>
|
||||
#include <units/current.h>
|
||||
#include <units/current.h>
|
||||
#include <units/temperature.h>
|
||||
#include <units/substance.h>
|
||||
#include <units/luminous_intensity.h>
|
||||
|
||||
#include <units/frequency.h>
|
||||
#include <units/velocity.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace {
|
||||
|
Reference in New Issue
Block a user