Predefined dimensions moved to a dedicated directory
This commit is contained in:
1 parent
9452cf5f3c
commit
7d70e6b1ce
24 files changed
+45
-44
No files matched your search
@@ -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 <units/dimensions/velocity.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_acceleration : make_dimension_t<exp<base_dim_length, 1>, exp<base_dim_time, -2>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_acceleration>> : downcast_to<dimension_acceleration> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Acceleration = Quantity<T> && std::Same<typename T::dimension, dimension_acceleration>;
|
||||
|
||||
struct metre_per_second_sq : derived_unit<dimension_acceleration, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<metre_per_second_sq>> : downcast_to<metre_per_second_sq> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// mps_sq
|
||||
constexpr auto operator""mps_sq(unsigned long long l) { return quantity<metre_per_second_sq, std::int64_t>(l); }
|
||||
constexpr auto operator""mps_sq(long double l) { return quantity<metre_per_second_sq, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,70 @@
|
||||
// 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/dimensions/length.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_area : make_dimension_t<exp<base_dim_length, 2>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_area>> : downcast_to<dimension_area> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Area = Quantity<T> && std::Same<typename T::dimension, dimension_area>;
|
||||
|
||||
struct square_millimetre : derived_unit<dimension_area, millimetre> {};
|
||||
template<> struct downcasting_traits<downcast_from<square_millimetre>> : downcast_to<square_millimetre> {};
|
||||
|
||||
struct square_centimetre : derived_unit<dimension_area, centimetre> {};
|
||||
template<> struct downcasting_traits<downcast_from<square_centimetre>> : downcast_to<square_centimetre> {};
|
||||
|
||||
struct square_metre : derived_unit<dimension_area, metre> {};
|
||||
template<> struct downcasting_traits<downcast_from<square_metre>> : downcast_to<square_metre> {};
|
||||
|
||||
struct square_kilometre : derived_unit<dimension_area, kilometre, metre> {};
|
||||
template<> struct downcasting_traits<downcast_from<square_kilometre>> : downcast_to<square_kilometre> {};
|
||||
|
||||
struct square_foot : derived_unit<dimension_area, foot> {};
|
||||
template<> struct downcasting_traits<downcast_from<square_foot>> : downcast_to<square_foot> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// sq_mm
|
||||
constexpr auto operator""sq_mm(unsigned long long l) { return quantity<square_millimetre, std::int64_t>(l); }
|
||||
constexpr auto operator""sq_mm(long double l) { return quantity<square_millimetre, long double>(l); }
|
||||
|
||||
// sq_cm
|
||||
constexpr auto operator""sq_cm(unsigned long long l) { return quantity<square_centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator""sq_cm(long double l) { return quantity<square_centimetre, long double>(l); }
|
||||
|
||||
// sq_m
|
||||
constexpr auto operator""sq_m(unsigned long long l) { return quantity<square_metre, std::int64_t>(l); }
|
||||
constexpr auto operator""sq_m(long double l) { return quantity<square_metre, long double>(l); }
|
||||
|
||||
// sq_km
|
||||
constexpr auto operator""sq_km(unsigned long long l) { return quantity<square_kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator""sq_km(long double l) { return quantity<square_kilometre, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,48 @@
|
||||
// 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/dimensions/electric_charge.h>
|
||||
#include <units/dimensions/voltage.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_capacitance : make_dimension_t<exp<base_dim_mass, -1>, exp<base_dim_length, -2>, exp<base_dim_time, 4>, exp<base_dim_current, 2>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_capacitance>> : downcast_to<dimension_capacitance> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Capacitance = Quantity<T> && std::Same<typename T::dimension, dimension_capacitance>;
|
||||
|
||||
struct farad : derived_unit<dimension_capacitance, kilogram, metre, second, ampere> {};
|
||||
template<> struct downcasting_traits<downcast_from<farad>> : downcast_to<farad> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// F
|
||||
constexpr auto operator""F(unsigned long long l) { return quantity<farad, std::int64_t>(l); }
|
||||
constexpr auto operator""_F(long double l) { return quantity<farad, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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 std::experimental::units {
|
||||
|
||||
struct dimension_current : make_dimension_t<exp<base_dim_current, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_current>> : downcast_to<dimension_current> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Current = Quantity<T> && std::Same<typename T::dimension, dimension_current>;
|
||||
|
||||
struct ampere : unit<dimension_current> {};
|
||||
template<> struct downcasting_traits<downcast_from<ampere>> : downcast_to<ampere> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// A
|
||||
constexpr auto operator""A(unsigned long long l) { return quantity<ampere, std::int64_t>(l); }
|
||||
constexpr auto operator""A(long double l) { return quantity<ampere, long double>(l); }
|
||||
|
||||
}
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,48 @@
|
||||
// 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/dimensions/time.h>
|
||||
#include <units/dimensions/current.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_electric_charge : make_dimension_t<exp<base_dim_time, 1>, exp<base_dim_current, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_electric_charge>> : downcast_to<dimension_electric_charge> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool ElectricCharge = Quantity<T> && std::Same<typename T::dimension, dimension_electric_charge>;
|
||||
|
||||
struct coulomb : derived_unit<dimension_electric_charge, second, ampere> {};
|
||||
template<> struct downcasting_traits<downcast_from<coulomb>> : downcast_to<coulomb> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// C
|
||||
constexpr auto operator""C(unsigned long long l) { return quantity<coulomb, std::int64_t>(l); }
|
||||
constexpr auto operator""C(long double l) { return quantity<coulomb, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,48 @@
|
||||
// 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/dimensions/force.h>
|
||||
#include <units/dimensions/pressure.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_energy : make_dimension_t<exp<base_dim_mass, 1>, exp<base_dim_length, 2>, exp<base_dim_time, -2>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_energy>> : downcast_to<dimension_energy> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Energy = Quantity<T> && std::Same<typename T::dimension, dimension_energy>;
|
||||
|
||||
struct joule : derived_unit<dimension_energy, kilogram, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<joule>> : downcast_to<joule> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// J
|
||||
constexpr auto operator""_J(unsigned long long l) { return quantity<joule, std::int64_t>(l); }
|
||||
constexpr auto operator""_J(long double l) { return quantity<joule, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,49 @@
|
||||
// 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/dimensions/mass.h>
|
||||
#include <units/dimensions/length.h>
|
||||
#include <units/dimensions/time.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_force : make_dimension_t<exp<base_dim_mass, 1>, exp<base_dim_length, 1>, exp<base_dim_time, -2>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_force>> : downcast_to<dimension_force> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Force = Quantity<T> && std::Same<typename T::dimension, dimension_force>;
|
||||
|
||||
struct newton : derived_unit<dimension_force, kilogram, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<newton>> : downcast_to<newton> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// N
|
||||
constexpr auto operator""N(unsigned long long l) { return quantity<newton, std::int64_t>(l); }
|
||||
constexpr auto operator""N(long double l) { return quantity<newton, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,82 @@
|
||||
// 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/dimensions/time.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_frequency : make_dimension_t<exp<base_dim_time, -1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_frequency>> : downcast_to<dimension_frequency> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Frequency = Quantity<T> && std::Same<typename T::dimension, dimension_frequency>;
|
||||
|
||||
struct hertz : derived_unit<dimension_frequency, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<hertz>> : downcast_to<hertz> {};
|
||||
|
||||
struct millihertz : milli<hertz> {};
|
||||
template<> struct downcasting_traits<downcast_from<millihertz>> : downcast_to<millihertz> {};
|
||||
|
||||
struct kilohertz : kilo<hertz> {};
|
||||
template<> struct downcasting_traits<downcast_from<kilohertz>> : downcast_to<kilohertz> {};
|
||||
|
||||
struct megahertz : mega<hertz> {};
|
||||
template<> struct downcasting_traits<downcast_from<megahertz>> : downcast_to<megahertz> {};
|
||||
|
||||
struct gigahertz : giga<hertz> {};
|
||||
template<> struct downcasting_traits<downcast_from<gigahertz>> : downcast_to<gigahertz> {};
|
||||
|
||||
struct terahertz : tera<hertz> {};
|
||||
template<> struct downcasting_traits<downcast_from<terahertz>> : downcast_to<terahertz> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// mHz
|
||||
constexpr auto operator""mHz(unsigned long long l) { return quantity<millihertz, std::int64_t>(l); }
|
||||
constexpr auto operator""mHz(long double l) { return quantity<millihertz, long double>(l); }
|
||||
|
||||
// Hz
|
||||
constexpr auto operator""Hz(unsigned long long l) { return quantity<hertz, std::int64_t>(l); }
|
||||
constexpr auto operator""Hz(long double l) { return quantity<hertz, long double>(l); }
|
||||
|
||||
// kHz
|
||||
constexpr auto operator""kHz(unsigned long long l) { return quantity<kilohertz, std::int64_t>(l); }
|
||||
constexpr auto operator""kHz(long double l) { return quantity<kilohertz, long double>(l); }
|
||||
|
||||
// MHz
|
||||
constexpr auto operator""MHz(unsigned long long l) { return quantity<megahertz, std::int64_t>(l); }
|
||||
constexpr auto operator""MHz(long double l) { return quantity<megahertz, long double>(l); }
|
||||
|
||||
// GHz
|
||||
constexpr auto operator""GHz(unsigned long long l) { return quantity<gigahertz, std::int64_t>(l); }
|
||||
constexpr auto operator""GHz(long double l) { return quantity<gigahertz, long double>(l); }
|
||||
|
||||
// THz
|
||||
constexpr auto operator""THz(unsigned long long l) { return quantity<terahertz, std::int64_t>(l); }
|
||||
constexpr auto operator""THz(long double l) { return quantity<terahertz, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,102 @@
|
||||
// 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 std::experimental::units {
|
||||
|
||||
struct dimension_length : make_dimension_t<exp<base_dim_length, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_length>> : downcast_to<dimension_length> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Length = Quantity<T> && std::Same<typename T::dimension, dimension_length>;
|
||||
|
||||
// SI units
|
||||
struct metre : unit<dimension_length> {};
|
||||
template<> struct downcasting_traits<downcast_from<metre>> : downcast_to<metre> {};
|
||||
|
||||
struct millimetre : milli<metre> {};
|
||||
template<> struct downcasting_traits<downcast_from<millimetre>> : downcast_to<millimetre> {};
|
||||
|
||||
struct centimetre : centi<metre> {};
|
||||
template<> struct downcasting_traits<downcast_from<centimetre>> : downcast_to<centimetre> {};
|
||||
|
||||
struct kilometre : kilo<metre> {};
|
||||
template<> struct downcasting_traits<downcast_from<kilometre>> : downcast_to<kilometre> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// mm
|
||||
constexpr auto operator""mm(unsigned long long l) { return quantity<millimetre, std::int64_t>(l); }
|
||||
constexpr auto operator""mm(long double l) { return quantity<millimetre, long double>(l); }
|
||||
|
||||
// cm
|
||||
constexpr auto operator""cm(unsigned long long l) { return quantity<centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator""cm(long double l) { return quantity<centimetre, long double>(l); }
|
||||
|
||||
// m
|
||||
constexpr auto operator""m(unsigned long long l) { return quantity<metre, std::int64_t>(l); }
|
||||
constexpr auto operator""m(long double l) { return quantity<metre, long double>(l); }
|
||||
|
||||
// km
|
||||
constexpr auto operator""km(unsigned long long l) { return quantity<kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator""km(long double l) { return quantity<kilometre, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
// US customary units
|
||||
struct yard : unit<dimension_length, ratio<9'144, 10'000>> {};
|
||||
template<> struct downcasting_traits<downcast_from<yard>> : downcast_to<yard> {};
|
||||
|
||||
struct foot : unit<dimension_length, ratio_multiply<ratio<1, 3>, yard::ratio>> {};
|
||||
template<> struct downcasting_traits<downcast_from<foot>> : downcast_to<foot> {};
|
||||
|
||||
struct inch : unit<dimension_length, ratio_multiply<ratio<1, 12>, foot::ratio>> {};
|
||||
template<> struct downcasting_traits<downcast_from<inch>> : downcast_to<inch> {};
|
||||
|
||||
struct mile : unit<dimension_length, ratio_multiply<ratio<1'760>, yard::ratio>> {};
|
||||
template<> struct downcasting_traits<downcast_from<mile>> : downcast_to<mile> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// yd
|
||||
constexpr auto operator""yd(unsigned long long l) { return quantity<yard, std::int64_t>(l); }
|
||||
constexpr auto operator""yd(long double l) { return quantity<yard, long double>(l); }
|
||||
|
||||
// ft
|
||||
constexpr auto operator""ft(unsigned long long l) { return quantity<foot, std::int64_t>(l); }
|
||||
constexpr auto operator""ft(long double l) { return quantity<foot, long double>(l); }
|
||||
|
||||
// in
|
||||
constexpr auto operator""in(unsigned long long l) { return quantity<inch, std::int64_t>(l); }
|
||||
constexpr auto operator""in(long double l) { return quantity<inch, long double>(l); }
|
||||
|
||||
// mi
|
||||
constexpr auto operator""mi(unsigned long long l) { return quantity<mile, std::int64_t>(l); }
|
||||
constexpr auto operator""mi(long double l) { return quantity<mile, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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 std::experimental::units {
|
||||
|
||||
struct dimension_luminous_intensity : make_dimension_t<exp<base_dim_luminous_intensity, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_luminous_intensity>> : downcast_to<dimension_luminous_intensity> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool LuminousIntensity = Quantity<T> && std::Same<typename T::dimension, dimension_luminous_intensity>;
|
||||
|
||||
struct candela : unit<dimension_luminous_intensity> {};
|
||||
template<> struct downcasting_traits<downcast_from<candela>> : downcast_to<candela> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// cd
|
||||
constexpr auto operator""cd(unsigned long long l) { return quantity<candela, std::int64_t>(l); }
|
||||
constexpr auto operator""cd(long double l) { return quantity<candela, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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 std::experimental::units {
|
||||
|
||||
struct dimension_mass : make_dimension_t<exp<base_dim_mass, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_mass>> : downcast_to<dimension_mass> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Mass = Quantity<T> && std::Same<typename T::dimension, dimension_mass>;
|
||||
|
||||
struct gram : unit<dimension_mass, ratio<1, 1000>> {};
|
||||
template<> struct downcasting_traits<downcast_from<gram>> : downcast_to<gram> {};
|
||||
|
||||
struct kilogram : kilo<gram> {};
|
||||
template<> struct downcasting_traits<downcast_from<kilogram>> : downcast_to<kilogram> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// g
|
||||
constexpr auto operator""g(unsigned long long l) { return quantity<gram, std::int64_t>(l); }
|
||||
constexpr auto operator""g(long double l) { return quantity<gram, long double>(l); }
|
||||
|
||||
// kg
|
||||
constexpr auto operator""kg(unsigned long long l) { return quantity<kilogram, std::int64_t>(l); }
|
||||
constexpr auto operator""kg(long double l) { return quantity<kilogram, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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/dimensions/energy.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_power : make_dimension_t<exp<base_dim_mass, 1>, exp<base_dim_length, 2>, exp<base_dim_time, -3>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_power>> : downcast_to<dimension_power> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Power = Quantity<T> && std::Same<typename T::dimension, dimension_power>;
|
||||
|
||||
struct watt : derived_unit<dimension_power, kilogram, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<watt>> : downcast_to<watt> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// W
|
||||
constexpr auto operator""W(unsigned long long l) { return quantity<watt, std::int64_t>(l); }
|
||||
constexpr auto operator""_W(long double l) { return quantity<watt, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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/dimensions/force.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_pressure : make_dimension_t<exp<base_dim_mass, 1>, exp<base_dim_length, -1>, exp<base_dim_time, -2>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_pressure>> : downcast_to<dimension_pressure> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Pressure = Quantity<T> && std::Same<typename T::dimension, dimension_pressure>;
|
||||
|
||||
struct pascal : derived_unit<dimension_pressure, kilogram, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<pascal>> : downcast_to<pascal> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// Pa
|
||||
constexpr auto operator""Pa(unsigned long long l) { return quantity<pascal, std::int64_t>(l); }
|
||||
constexpr auto operator""Pa(long double l) { return quantity<pascal, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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 std::experimental::units {
|
||||
|
||||
struct dimension_substance : make_dimension_t<exp<base_dim_substance, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_substance>> : downcast_to<dimension_substance> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Substance = Quantity<T> && std::Same<typename T::dimension, dimension_substance>;
|
||||
|
||||
struct mole : unit<dimension_substance> {};
|
||||
template<> struct downcasting_traits<downcast_from<mole>> : downcast_to<mole> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// mol
|
||||
constexpr auto operator""mol(unsigned long long l) { return quantity<mole, std::int64_t>(l); }
|
||||
constexpr auto operator""mol(long double l) { return quantity<mole, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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 std::experimental::units {
|
||||
|
||||
struct dimension_temperature : make_dimension_t<exp<base_dim_temperature, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_temperature>> : downcast_to<dimension_temperature> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool ThermodynamicTemperature = Quantity<T> && std::Same<typename T::dimension, dimension_temperature>;
|
||||
|
||||
struct kelvin : unit<dimension_temperature> {};
|
||||
template<> struct downcasting_traits<downcast_from<kelvin>> : downcast_to<kelvin> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// K
|
||||
constexpr auto operator""K(unsigned long long l) { return quantity<kelvin, std::int64_t>(l); }
|
||||
constexpr auto operator""_K(long double l) { return quantity<kelvin, long double>(l); } // todo: conflicts with gcc GNU extension
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,82 @@
|
||||
// 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 std::experimental::units {
|
||||
|
||||
struct dimension_time : make_dimension_t<exp<base_dim_time, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_time>> : downcast_to<dimension_time> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Time = Quantity<T> && std::Same<typename T::dimension, dimension_time>;
|
||||
|
||||
struct second : unit<dimension_time> {};
|
||||
template<> struct downcasting_traits<downcast_from<second>> : downcast_to<second> {};
|
||||
|
||||
struct nanosecond : nano<second> {};
|
||||
template<> struct downcasting_traits<downcast_from<nanosecond>> : downcast_to<nanosecond> {};
|
||||
|
||||
struct microsecond : micro<second> {};
|
||||
template<> struct downcasting_traits<downcast_from<microsecond>> : downcast_to<microsecond> {};
|
||||
|
||||
struct millisecond : milli<second> {};
|
||||
template<> struct downcasting_traits<downcast_from<millisecond>> : downcast_to<millisecond> {};
|
||||
|
||||
struct minute : unit<dimension_time, ratio<60>> {};
|
||||
template<> struct downcasting_traits<downcast_from<minute>> : downcast_to<minute> {};
|
||||
|
||||
struct hour : unit<dimension_time, ratio<3600>> {};
|
||||
template<> struct downcasting_traits<downcast_from<hour>> : downcast_to<hour> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// ns
|
||||
constexpr auto operator""ns(unsigned long long l) { return quantity<nanosecond, std::int64_t>(l); }
|
||||
constexpr auto operator""ns(long double l) { return quantity<nanosecond, long double>(l); }
|
||||
|
||||
// us
|
||||
constexpr auto operator""us(unsigned long long l) { return quantity<microsecond, std::int64_t>(l); }
|
||||
constexpr auto operator""us(long double l) { return quantity<microsecond, long double>(l); }
|
||||
|
||||
// ms
|
||||
constexpr auto operator""ms(unsigned long long l) { return quantity<millisecond, std::int64_t>(l); }
|
||||
constexpr auto operator""ms(long double l) { return quantity<millisecond, long double>(l); }
|
||||
|
||||
// s
|
||||
constexpr auto operator""s(unsigned long long l) { return quantity<second, std::int64_t>(l); }
|
||||
constexpr auto operator""s(long double l) { return quantity<second, long double>(l); }
|
||||
|
||||
// min
|
||||
constexpr auto operator""min(unsigned long long l) { return quantity<minute, std::int64_t>(l); }
|
||||
constexpr auto operator""min(long double l) { return quantity<minute, long double>(l); }
|
||||
|
||||
// h
|
||||
constexpr auto operator""h(unsigned long long l) { return quantity<hour, std::int64_t>(l); }
|
||||
constexpr auto operator""h(long double l) { return quantity<hour, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,61 @@
|
||||
// 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/dimensions/length.h>
|
||||
#include <units/dimensions/time.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_velocity : make_dimension_t<exp<base_dim_length, 1>, exp<base_dim_time, -1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_velocity>> : downcast_to<dimension_velocity> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Velocity = Quantity<T> && std::Same<typename T::dimension, dimension_velocity>;
|
||||
|
||||
struct metre_per_second : derived_unit<dimension_velocity, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<metre_per_second>> : downcast_to<metre_per_second> {};
|
||||
|
||||
struct kilometre_per_hour : derived_unit<dimension_velocity, kilometre, hour> {};
|
||||
template<> struct downcasting_traits<downcast_from<kilometre_per_hour>> : downcast_to<kilometre_per_hour> {};
|
||||
|
||||
struct mile_per_hour : derived_unit<dimension_velocity, mile, hour> {};
|
||||
template<> struct downcasting_traits<downcast_from<mile_per_hour>> : downcast_to<mile_per_hour> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// mps
|
||||
constexpr auto operator""mps(unsigned long long l) { return quantity<metre_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator""mps(long double l) { return quantity<metre_per_second, long double>(l); }
|
||||
|
||||
// kmph
|
||||
constexpr auto operator""kmph(unsigned long long l) { return quantity<kilometre_per_hour, std::int64_t>(l); }
|
||||
constexpr auto operator""kmph(long double l) { return quantity<kilometre_per_hour, long double>(l); }
|
||||
|
||||
// mph
|
||||
constexpr auto operator""mph(unsigned long long l) { return quantity<mile_per_hour, std::int64_t>(l); }
|
||||
constexpr auto operator""mph(long double l) { return quantity<mile_per_hour, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -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/dimensions/power.h>
|
||||
#include <units/dimensions/current.h>
|
||||
#include <units/dimensions/energy.h>
|
||||
#include <units/dimensions/electric_charge.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_voltage : make_dimension_t<exp<base_dim_mass, 1>, exp<base_dim_length, 2>, exp<base_dim_time, -3>, exp<base_dim_current, -1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_voltage>> : downcast_to<dimension_voltage> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Voltage = Quantity<T> && std::Same<typename T::dimension, dimension_voltage>;
|
||||
|
||||
struct volt : derived_unit<dimension_voltage, kilogram, metre, second, ampere> {};
|
||||
template<> struct downcasting_traits<downcast_from<volt>> : downcast_to<volt> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// V
|
||||
constexpr auto operator""V(unsigned long long l) { return quantity<volt, std::int64_t>(l); }
|
||||
constexpr auto operator""V(long double l) { return quantity<volt, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
@@ -0,0 +1,70 @@
|
||||
// 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/dimensions/length.h>
|
||||
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_volume : make_dimension_t<exp<base_dim_length, 3>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_volume>> : downcast_to<dimension_volume> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Volume = Quantity<T> && std::Same<typename T::dimension, dimension_volume>;
|
||||
|
||||
struct cubic_millimetre : derived_unit<dimension_volume, millimetre> {};
|
||||
template<> struct downcasting_traits<downcast_from<cubic_millimetre>> : downcast_to<cubic_millimetre> {};
|
||||
|
||||
struct cubic_centimetre : derived_unit<dimension_volume, centimetre> {};
|
||||
template<> struct downcasting_traits<downcast_from<cubic_centimetre>> : downcast_to<cubic_centimetre> {};
|
||||
|
||||
struct cubic_metre : derived_unit<dimension_volume, metre> {};
|
||||
template<> struct downcasting_traits<downcast_from<cubic_metre>> : downcast_to<cubic_metre> {};
|
||||
|
||||
struct cubic_kilometre : derived_unit<dimension_volume, kilometre, metre> {};
|
||||
template<> struct downcasting_traits<downcast_from<cubic_kilometre>> : downcast_to<cubic_kilometre> {};
|
||||
|
||||
struct cubic_foot : derived_unit<dimension_volume, foot> {};
|
||||
template<> struct downcasting_traits<downcast_from<cubic_foot>> : downcast_to<cubic_foot> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// cub_mm
|
||||
constexpr auto operator""cub_mm(unsigned long long l) { return quantity<cubic_millimetre, std::int64_t>(l); }
|
||||
constexpr auto operator""cub_mm(long double l) { return quantity<cubic_millimetre, long double>(l); }
|
||||
|
||||
// cub_cm
|
||||
constexpr auto operator""cub_cm(unsigned long long l) { return quantity<cubic_centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator""cub_cm(long double l) { return quantity<cubic_centimetre, long double>(l); }
|
||||
|
||||
// cub_m
|
||||
constexpr auto operator""cub_m(unsigned long long l) { return quantity<cubic_metre, std::int64_t>(l); }
|
||||
constexpr auto operator""cub_m(long double l) { return quantity<cubic_metre, long double>(l); }
|
||||
|
||||
// cub_km
|
||||
constexpr auto operator""cub_km(unsigned long long l) { return quantity<cubic_kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator""cub_km(long double l) { return quantity<cubic_kilometre, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace std::experimental::units
|
||||
Reference in new issue
Block a user