forked from mpusz/mp-units
All UDLs are now prefixed with q_
This commit is contained in:
28
README.md
28
README.md
@@ -25,7 +25,7 @@ constexpr Velocity auto avg_speed(Length auto d, Time auto t)
|
||||
int main()
|
||||
{
|
||||
using namespace si::literals;
|
||||
Velocity auto v1 = avg_speed(220km, 2h);
|
||||
Velocity auto v1 = avg_speed(220q_km, 2q_h);
|
||||
Velocity auto v2 = avg_speed(si::length<international::mile>(140), si::time<si::hour>(2));
|
||||
Velocity auto v3 = quantity_cast<si::metre_per_second>(v2);
|
||||
Velocity auto v4 = quantity_cast<int>(v3);
|
||||
@@ -50,20 +50,20 @@ Here is a small example of possible operations:
|
||||
|
||||
```cpp
|
||||
// simple numeric operations
|
||||
static_assert(10km / 2 == 5km);
|
||||
static_assert(10q_km / 2 == 5q_km);
|
||||
|
||||
// unit conversions
|
||||
static_assert(1h == 3600s);
|
||||
static_assert(1km + 1m == 1001m);
|
||||
static_assert(1q_h == 3600q_s);
|
||||
static_assert(1q_km + 1q_m == 1001q_m);
|
||||
|
||||
// dimension conversions
|
||||
static_assert(1km / 1s == 1000mps);
|
||||
static_assert(2kmph * 2h == 4km);
|
||||
static_assert(2km / 2kmph == 1h);
|
||||
static_assert(1q_km / 1q_s == 1000q_mps);
|
||||
static_assert(2q_kmph * 2q_h == 4q_km);
|
||||
static_assert(2q_km / 2q_kmph == 1q_h);
|
||||
|
||||
static_assert(1000 / 1s == 1kHz);
|
||||
static_assert(1000 / 1q_s == 1q_kHz);
|
||||
|
||||
static_assert(10km / 5km == 2);
|
||||
static_assert(10q_km / 5q_km == 2);
|
||||
```
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ Thanks to them the same code can be as simple as:
|
||||
|
||||
```cpp
|
||||
using namespace units::si::literals;
|
||||
auto d = 123km; // units::length<units::si::kilometre, std::int64_t>
|
||||
auto d = 123q_km; // units::length<units::si::kilometre, std::int64_t>
|
||||
```
|
||||
|
||||
For brevity, the next examples will assume:
|
||||
@@ -105,8 +105,8 @@ Let's assume that the user wants to write the following code:
|
||||
int main()
|
||||
{
|
||||
using namespace si::literals;
|
||||
auto v1 = avg_speed(220km, 2h);
|
||||
auto v2 = avg_speed(140mi, 2h);
|
||||
auto v1 = avg_speed(220q_km, 2q_h);
|
||||
auto v2 = avg_speed(140q_mi, 2q_h);
|
||||
// ...
|
||||
}
|
||||
```
|
||||
@@ -156,8 +156,8 @@ int main()
|
||||
{
|
||||
using namespace si::literals;
|
||||
using namespace international::literals;
|
||||
Velocity auto v1 = avg_speed(220km, 2h);
|
||||
Velocity auto v2 = avg_speed(140mi, 2h);
|
||||
Velocity auto v1 = avg_speed(220q_km, 2q_h);
|
||||
Velocity auto v2 = avg_speed(140q_mi, 2q_h);
|
||||
|
||||
std::cout << v1 << '\n'; // 110 km/h
|
||||
std::cout << quantity_cast<si::metre_per_second>(speed) << '\n'; // 30.5556 m/s
|
||||
|
@@ -11,20 +11,20 @@ Here is a small example of possible operations:
|
||||
|
||||
```cpp
|
||||
// simple numeric operations
|
||||
static_assert(10km / 2 == 5km);
|
||||
static_assert(10q_km / 2 == 5q_km);
|
||||
|
||||
// unit conversions
|
||||
static_assert(1h == 3600s);
|
||||
static_assert(1km + 1m == 1001m);
|
||||
static_assert(1q_h == 3600q_s);
|
||||
static_assert(1q_km + 1q_m == 1001q_m);
|
||||
|
||||
// dimension conversions
|
||||
static_assert(1km / 1s == 1000mps);
|
||||
static_assert(2kmph * 2h == 4km);
|
||||
static_assert(2km / 2kmph == 1h);
|
||||
static_assert(1q_km / 1q_s == 1000q_mps);
|
||||
static_assert(2q_kmph * 2q_h == 4q_km);
|
||||
static_assert(2q_km / 2q_kmph == 1q_h);
|
||||
|
||||
static_assert(1000 / 1s == 1kHz);
|
||||
static_assert(1000 / 1q_s == 1q_kHz);
|
||||
|
||||
static_assert(10km / 5km == 2);
|
||||
static_assert(10q_km / 5q_km == 2);
|
||||
```
|
||||
|
||||
|
||||
@@ -458,12 +458,12 @@ has an associated UDL. For example:
|
||||
namespace si::inline literals {
|
||||
|
||||
// m
|
||||
constexpr auto operator"" m(unsigned long long l) { return length<metre, std::int64_t>(l); }
|
||||
constexpr auto operator"" m(long double l) { return length<metre, long double>(l); }
|
||||
constexpr auto operator"" q_m(unsigned long long l) { return length<metre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_m(long double l) { return length<metre, long double>(l); }
|
||||
|
||||
// km
|
||||
constexpr auto operator"" km(unsigned long long l) { return length<kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" km(long double l) { return length<kilometre, long double>(l); }
|
||||
constexpr auto operator"" q_km(unsigned long long l) { return length<kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_km(long double l) { return length<kilometre, long double>(l); }
|
||||
|
||||
}
|
||||
```
|
||||
@@ -574,7 +574,7 @@ If the `units-specs` is omitted, the `quantity` object is formatted as if by str
|
||||
additional padding and adjustments as specified by the format specifiers.
|
||||
|
||||
```cpp
|
||||
std::string s = fmt::format("{:=>12}", 120_kmph); // value of s is "====120 km/h"
|
||||
std::string s = fmt::format("{:=>12}", 120q_kmph); // value of s is "====120 km/h"
|
||||
```
|
||||
|
||||
|
||||
@@ -732,14 +732,14 @@ predefined by the user in the downcasting facility. A typical example of such a
|
||||
temporary results of calculations:
|
||||
|
||||
```cpp
|
||||
units::Length auto d1 = 123m;
|
||||
units::Time auto t1 = 10s;
|
||||
units::Length auto d1 = 123q_m;
|
||||
units::Time auto t1 = 10q_s;
|
||||
units::Velocity auto v1 = avg_speed(d1, t1);
|
||||
|
||||
auto temp1 = v1 * 50m; // intermediate unknown dimension
|
||||
auto temp1 = v1 * 50q_m; // intermediate unknown dimension
|
||||
|
||||
units::Velocity auto v2 = temp1 / 100m; // back to known dimensions again
|
||||
units::Length auto d2 = v2 * 60s;
|
||||
units::Velocity auto v2 = temp1 / 100q_m; // back to known dimensions again
|
||||
units::Length auto d2 = v2 * 60q_s;
|
||||
```
|
||||
|
||||
To provide support to form an unknown derived dimension that could be than be converted to a
|
||||
@@ -825,12 +825,12 @@ adds support for digital information quantities. In summary it adds:
|
||||
namespace units::data::inline literals {
|
||||
|
||||
// bits
|
||||
constexpr auto operator""b(unsigned long long l) { return information<bit, std::int64_t>(l); }
|
||||
constexpr auto operator""Kib(unsigned long long l) { return information<kibibit, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_b(unsigned long long l) { return information<bit, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Kib(unsigned long long l) { return information<kibibit, std::int64_t>(l); }
|
||||
|
||||
// bytes
|
||||
constexpr auto operator""B(unsigned long long l) { return information<byte, std::int64_t>(l); }
|
||||
constexpr auto operator""KiB(unsigned long long l) { return information<kibibyte, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_B(unsigned long long l) { return information<byte, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_KiB(unsigned long long l) { return information<kibibyte, std::int64_t>(l); }
|
||||
|
||||
}
|
||||
```
|
||||
@@ -854,8 +854,8 @@ adds support for digital information quantities. In summary it adds:
|
||||
inline namespace literals {
|
||||
|
||||
// bits
|
||||
constexpr auto operator""_bps(unsigned long long l) { return bitrate<bit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator""_Kibps(unsigned long long l) { return bitrate<kibibit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_bps(unsigned long long l) { return bitrate<bit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Kibps(unsigned long long l) { return bitrate<kibibit_per_second, std::int64_t>(l); }
|
||||
|
||||
}
|
||||
|
||||
|
@@ -68,7 +68,7 @@ void example()
|
||||
// SI (int)
|
||||
{
|
||||
using namespace units::si::literals;
|
||||
constexpr Length AUTO distance = 220km; // constructed from a UDL
|
||||
constexpr Length AUTO distance = 220q_km; // constructed from a UDL
|
||||
constexpr si::time<si::hour, int> duration(2); // constructed from a value
|
||||
|
||||
std::cout << "SI units with 'int' as representation\n";
|
||||
@@ -82,8 +82,8 @@ void example()
|
||||
// SI (double)
|
||||
{
|
||||
using namespace units::si::literals;
|
||||
constexpr Length AUTO distance = 220.km; // constructed from a UDL
|
||||
constexpr si::time<si::hour> duration(2); // constructed from a value
|
||||
constexpr Length AUTO distance = 220.q_km; // constructed from a UDL
|
||||
constexpr si::time<si::hour> duration(2); // constructed from a value
|
||||
|
||||
std::cout << "\nSI units with 'double' as representation\n";
|
||||
|
||||
@@ -98,7 +98,7 @@ void example()
|
||||
// Customary Units (int)
|
||||
{
|
||||
using namespace units::international::literals;
|
||||
constexpr Length AUTO distance = 140mi; // constructed from a UDL
|
||||
constexpr Length AUTO distance = 140q_mi; // constructed from a UDL
|
||||
constexpr si::time<si::hour, int> duration(2); // constructed from a value
|
||||
|
||||
std::cout << "\nUS Customary Units with 'int' as representation\n";
|
||||
@@ -114,7 +114,7 @@ void example()
|
||||
// Customary Units (double)
|
||||
{
|
||||
using namespace units::international::literals;
|
||||
constexpr Length AUTO distance = 140.mi; // constructed from a UDL
|
||||
constexpr Length AUTO distance = 140q_mi; // constructed from a UDL
|
||||
constexpr si::time<si::hour> duration(2); // constructed from a value
|
||||
|
||||
std::cout << "\nUS Customary Units with 'double' as representation\n";
|
||||
@@ -132,8 +132,8 @@ void example()
|
||||
// CGS (int)
|
||||
{
|
||||
using namespace units::cgs::literals;
|
||||
constexpr Length AUTO distance = 22'000'000cm; // constructed from a UDL
|
||||
constexpr cgs::time<si::hour, int> duration(2); // constructed from a value
|
||||
constexpr Length AUTO distance = 22'000'000q_cm; // constructed from a UDL
|
||||
constexpr cgs::time<si::hour, int> duration(2); // constructed from a value
|
||||
|
||||
std::cout << "\nCGS units with 'int' as representation\n";
|
||||
|
||||
@@ -151,8 +151,8 @@ void example()
|
||||
// CGS (double)
|
||||
{
|
||||
using namespace units::cgs::literals;
|
||||
constexpr Length AUTO distance = 22'000'000.cm; // constructed from a UDL
|
||||
constexpr cgs::time<si::hour> duration(2); // constructed from a value
|
||||
constexpr Length AUTO distance = 22'000'000q_cm; // constructed from a UDL
|
||||
constexpr cgs::time<si::hour> duration(2); // constructed from a value
|
||||
|
||||
std::cout << "\nCGS units with 'double' as representation\n";
|
||||
|
||||
|
@@ -101,11 +101,11 @@ struct Box {
|
||||
using namespace units::si::literals;
|
||||
int main()
|
||||
{
|
||||
auto box = Box{1000.0mm, 500.0mm, 200.0mm};
|
||||
box.set_contents_density(1000.0kgpm3);
|
||||
auto box = Box{1000.0q_mm, 500.0q_mm, 200.0q_mm};
|
||||
box.set_contents_density(1000.0q_kgpm3);
|
||||
|
||||
auto fill_time = 200.0s; // time since starting fill
|
||||
auto measured_mass = 20.0kg; // measured mass at fill_time
|
||||
auto fill_time = 200.0q_s; // time since starting fill
|
||||
auto measured_mass = 20.0q_kg; // measured mass at fill_time
|
||||
|
||||
std::cout << "mpusz/units box example...\n";
|
||||
std::cout << "fill height at " << fill_time << " = " << box.fill_level(measured_mass) << " ("
|
||||
|
@@ -56,22 +56,22 @@ int main()
|
||||
std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
|
||||
std::cout.precision(3);
|
||||
|
||||
constexpr auto C = 0.47uF;
|
||||
constexpr auto V0 = 5.0V;
|
||||
constexpr auto R = 4.7kR;
|
||||
constexpr auto C = 0.47q_uF;
|
||||
constexpr auto V0 = 5.0q_V;
|
||||
constexpr auto R = 4.7q_kR;
|
||||
|
||||
for (auto t = 0ms; t <= 50ms; ++t) {
|
||||
for (auto t = 0q_ms; t <= 50q_ms; ++t) {
|
||||
const auto Vt = V0 * std::exp(-t / (R * C));
|
||||
|
||||
std::cout << "at " << t << " voltage is ";
|
||||
|
||||
if (Vt >= 1V)
|
||||
if (Vt >= 1q_V)
|
||||
std::cout << Vt;
|
||||
else if (Vt >= 1mV)
|
||||
else if (Vt >= 1q_mV)
|
||||
std::cout << voltage::mV<>{Vt};
|
||||
else if (Vt >= 1uV)
|
||||
else if (Vt >= 1q_uV)
|
||||
std::cout << voltage::uV<>{Vt};
|
||||
else if (Vt >= 1nV)
|
||||
else if (Vt >= 1q_nV)
|
||||
std::cout << voltage::nV<>{Vt};
|
||||
else
|
||||
std::cout << voltage::pV<>{Vt};
|
||||
|
@@ -130,12 +130,12 @@ void simple_quantities()
|
||||
using distance = length::m<>;
|
||||
using time = time::s<>;
|
||||
|
||||
constexpr distance km = 1.0km;
|
||||
constexpr distance miles = 1.0mi;
|
||||
constexpr distance km = 1.0q_km;
|
||||
constexpr distance miles = 1.0q_mi;
|
||||
|
||||
constexpr time sec = 1s;
|
||||
constexpr time min = 1min;
|
||||
constexpr time hr = 1h;
|
||||
constexpr time sec = 1q_s;
|
||||
constexpr time min = 1q_min;
|
||||
constexpr time hr = 1q_h;
|
||||
|
||||
std::cout << "A physical quantities library can choose the simple\n";
|
||||
std::cout << "option to provide output using a single type for each base unit:\n\n";
|
||||
@@ -148,14 +148,14 @@ void simple_quantities()
|
||||
|
||||
void quantities_with_typed_units()
|
||||
{
|
||||
constexpr length::km<> km = 1.0km;
|
||||
constexpr length::mi<> miles = 1.0mi;
|
||||
constexpr length::km<> km = 1.0q_km;
|
||||
constexpr length::mi<> miles = 1.0q_mi;
|
||||
|
||||
std::cout.precision(6);
|
||||
|
||||
constexpr time::s<> sec = 1s;
|
||||
constexpr time::min<> min = 1min;
|
||||
constexpr time::h<> hr = 1h;
|
||||
constexpr time::s<> sec = 1q_s;
|
||||
constexpr time::min<> min = 1q_min;
|
||||
constexpr time::h<> hr = 1q_h;
|
||||
|
||||
std::cout << "A more flexible option is to provide separate types for each unit,\n\n";
|
||||
std::cout << km << '\n';
|
||||
@@ -164,7 +164,7 @@ void quantities_with_typed_units()
|
||||
std::cout << min << '\n';
|
||||
std::cout << hr << "\n\n";
|
||||
|
||||
constexpr length::m<> meter = 1m;
|
||||
constexpr length::m<> meter = 1q_m;
|
||||
std::cout << "then a wide range of pre-defined units can be defined and converted,\n"
|
||||
" for consistency and repeatability across applications:\n\n";
|
||||
|
||||
@@ -197,8 +197,8 @@ void calcs_comparison()
|
||||
"when adding two values of the same very big\n"
|
||||
"or very small type:\n\n";
|
||||
|
||||
length::fm<float> L1A = 2fm;
|
||||
length::fm<float> L2A = 3fm;
|
||||
length::fm<float> L1A = 2q_fm;
|
||||
length::fm<float> L2A = 3q_fm;
|
||||
length::fm<float> LrA = L1A + L2A;
|
||||
|
||||
std::cout << L1A << " + " << L2A << " = " << LrA << "\n\n";
|
||||
|
@@ -64,7 +64,7 @@ int main()
|
||||
{
|
||||
std::cout << "conversion factor in mpusz/units...\n\n";
|
||||
|
||||
constexpr length::m<> lengthA = 2.0m;
|
||||
constexpr length::m<> lengthA = 2.0q_m;
|
||||
constexpr length::mm<> lengthB = lengthA;
|
||||
|
||||
std::cout << "lengthA( " << lengthA << " ) and lengthB( " << lengthB << " )\n"
|
||||
|
@@ -35,7 +35,7 @@ constexpr Velocity AUTO avg_speed(Length AUTO d, Time AUTO t)
|
||||
int main()
|
||||
{
|
||||
using namespace si::literals;
|
||||
Velocity AUTO v1 = avg_speed(220km, 2h);
|
||||
Velocity AUTO v1 = avg_speed(220q_km, 2q_h);
|
||||
Velocity AUTO v2 = avg_speed(si::length<international::mile>(140), si::time<si::hour>(2));
|
||||
Velocity AUTO v3 = quantity_cast<si::metre_per_second>(v2);
|
||||
Velocity AUTO v4 = quantity_cast<int>(v3);
|
||||
|
@@ -35,13 +35,13 @@ void example()
|
||||
{
|
||||
using namespace units::si::literals;
|
||||
|
||||
units::Length AUTO d1 = 123m;
|
||||
units::Time AUTO t1 = 10s;
|
||||
units::Length AUTO d1 = 123q_m;
|
||||
units::Time AUTO t1 = 10q_s;
|
||||
units::Velocity AUTO v1 = avg_speed(d1, t1);
|
||||
|
||||
auto temp1 = v1 * 50m; // produces intermediate unknown dimension with 'unknown_unit' as its 'coherent_unit'
|
||||
units::Velocity AUTO v2 = temp1 / 100m; // back to known dimensions again
|
||||
units::Length AUTO d2 = v2 * 60s;
|
||||
auto temp1 = v1 * 50q_m; // produces intermediate unknown dimension with 'unknown_unit' as its 'coherent_unit'
|
||||
units::Velocity AUTO v2 = temp1 / 100q_m; // back to known dimensions again
|
||||
units::Length AUTO d2 = v2 * 60q_s;
|
||||
|
||||
std::cout << "d1 = " << d1 << '\n';
|
||||
std::cout << "t1 = " << t1 << '\n';
|
||||
|
@@ -47,12 +47,12 @@ using bitrate = quantity<dim_bitrate, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// bits
|
||||
constexpr auto operator""bps(unsigned long long l) { return bitrate<bit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator""Kibps(unsigned long long l) { return bitrate<kibibit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator""Mibps(unsigned long long l) { return bitrate<mebibit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator""Gibps(unsigned long long l) { return bitrate<gibibit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator""Tibps(unsigned long long l) { return bitrate<tebibit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator""sPibps(unsigned long long l) { return bitrate<pebibit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_bps(unsigned long long l) { return bitrate<bit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Kibps(unsigned long long l) { return bitrate<kibibit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Mibps(unsigned long long l) { return bitrate<mebibit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Gibps(unsigned long long l) { return bitrate<gibibit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Tibps(unsigned long long l) { return bitrate<tebibit_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_sPibps(unsigned long long l) { return bitrate<pebibit_per_second, std::int64_t>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -54,20 +54,20 @@ using information = quantity<dim_information, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// bits
|
||||
constexpr auto operator""b(unsigned long long l) { return information<bit, std::int64_t>(l); }
|
||||
constexpr auto operator""Kib(unsigned long long l) { return information<kibibit, std::int64_t>(l); }
|
||||
constexpr auto operator""Mib(unsigned long long l) { return information<mebibit, std::int64_t>(l); }
|
||||
constexpr auto operator""Gib(unsigned long long l) { return information<gibibit, std::int64_t>(l); }
|
||||
constexpr auto operator""Tib(unsigned long long l) { return information<tebibit, std::int64_t>(l); }
|
||||
constexpr auto operator""Pib(unsigned long long l) { return information<pebibit, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_b(unsigned long long l) { return information<bit, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Kib(unsigned long long l) { return information<kibibit, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Mib(unsigned long long l) { return information<mebibit, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Gib(unsigned long long l) { return information<gibibit, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Tib(unsigned long long l) { return information<tebibit, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Pib(unsigned long long l) { return information<pebibit, std::int64_t>(l); }
|
||||
|
||||
// bytes
|
||||
constexpr auto operator""B(unsigned long long l) { return information<byte, std::int64_t>(l); }
|
||||
constexpr auto operator""KiB(unsigned long long l) { return information<kibibyte, std::int64_t>(l); }
|
||||
constexpr auto operator""MiB(unsigned long long l) { return information<mebibyte, std::int64_t>(l); }
|
||||
constexpr auto operator""GiB(unsigned long long l) { return information<gibibyte, std::int64_t>(l); }
|
||||
constexpr auto operator""TiB(unsigned long long l) { return information<tebibyte, std::int64_t>(l); }
|
||||
constexpr auto operator""PiB(unsigned long long l) { return information<pebibyte, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_B(unsigned long long l) { return information<byte, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_KiB(unsigned long long l) { return information<kibibyte, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_MiB(unsigned long long l) { return information<mebibyte, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_GiB(unsigned long long l) { return information<gibibyte, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_TiB(unsigned long long l) { return information<tebibyte, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_PiB(unsigned long long l) { return information<pebibyte, std::int64_t>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -37,8 +37,8 @@ using acceleration = quantity<dim_acceleration, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// Gal
|
||||
constexpr auto operator""Gal(unsigned long long l) { return acceleration<gal, std::int64_t>(l); }
|
||||
constexpr auto operator""Gal(long double l) { return acceleration<gal, long double>(l); }
|
||||
constexpr auto operator"" q_Gal(unsigned long long l) { return acceleration<gal, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Gal(long double l) { return acceleration<gal, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -39,8 +39,8 @@ using area = quantity<dim_area, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// cm2
|
||||
constexpr auto operator"" cm2(unsigned long long l) { return area<square_centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" cm2(long double l) { return area<square_centimetre, long double>(l); }
|
||||
constexpr auto operator"" q_cm2(unsigned long long l) { return area<square_centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_cm2(long double l) { return area<square_centimetre, long double>(l); }
|
||||
|
||||
}
|
||||
|
||||
|
@@ -39,8 +39,8 @@ using energy = quantity<dim_energy, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// erg
|
||||
constexpr auto operator""_erg(unsigned long long l) { return energy<erg, std::int64_t>(l); }
|
||||
constexpr auto operator""_erg(long double l) { return energy<erg, long double>(l); }
|
||||
constexpr auto operator"" q_erg(unsigned long long l) { return energy<erg, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_erg(long double l) { return energy<erg, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -40,8 +40,8 @@ using force = quantity<dim_force, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// dyn
|
||||
constexpr auto operator""dyn(unsigned long long l) { return force<dyne, std::int64_t>(l); }
|
||||
constexpr auto operator""dyn(long double l) { return force<dyne, long double>(l); }
|
||||
constexpr auto operator"" q_dyn(unsigned long long l) { return force<dyne, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_dyn(long double l) { return force<dyne, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -38,8 +38,8 @@ using length = quantity<dim_length, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// cm
|
||||
constexpr auto operator"" cm(unsigned long long l) { return length<centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" cm(long double l) { return length<centimetre, long double>(l); }
|
||||
constexpr auto operator"" q_cm(unsigned long long l) { return length<centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_cm(long double l) { return length<centimetre, long double>(l); }
|
||||
|
||||
}
|
||||
|
||||
|
@@ -38,8 +38,8 @@ using mass = quantity<dim_mass, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// g
|
||||
constexpr auto operator""g(unsigned long long l) { return mass<gram, std::int64_t>(l); }
|
||||
constexpr auto operator""g(long double l) { return mass<gram, long double>(l); }
|
||||
constexpr auto operator"" q_g(unsigned long long l) { return mass<gram, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_g(long double l) { return mass<gram, long double>(l); }
|
||||
|
||||
}
|
||||
|
||||
|
@@ -39,8 +39,8 @@ using power = quantity<dim_power, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// ergps
|
||||
constexpr auto operator""_ergps(unsigned long long l) { return power<erg_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator""_ergps(long double l) { return power<erg_per_second, long double>(l); }
|
||||
constexpr auto operator"" q_ergps(unsigned long long l) { return power<erg_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ergps(long double l) { return power<erg_per_second, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -40,8 +40,8 @@ using pressure = quantity<dim_pressure, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// Ba
|
||||
constexpr auto operator""Ba(unsigned long long l) { return pressure<barye, std::int64_t>(l); }
|
||||
constexpr auto operator""Ba(long double l) { return pressure<barye, long double>(l); }
|
||||
constexpr auto operator"" q_Ba(unsigned long long l) { return pressure<barye, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Ba(long double l) { return pressure<barye, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -35,7 +35,7 @@ using si::time;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
using si::literals::operator"" s;
|
||||
using si::literals::operator"" q_s;
|
||||
|
||||
}
|
||||
|
||||
|
@@ -38,8 +38,8 @@ using velocity = quantity<dim_velocity, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// cmps
|
||||
constexpr auto operator"" cmps(unsigned long long l) { return velocity<centimetre_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" cmps(long double l) { return velocity<centimetre_per_second, long double>(l); }
|
||||
constexpr auto operator"" q_cmps(unsigned long long l) { return velocity<centimetre_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_cmps(long double l) { return velocity<centimetre_per_second, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -38,14 +38,14 @@ struct angstrom : named_scaled_unit<angstrom, "angstrom", no_prefix, ratio<1, 1,
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
constexpr auto operator"" ly(unsigned long long l) { return si::length<light_year, std::int64_t>(l); }
|
||||
constexpr auto operator"" ly(long double l) { return si::length<light_year, long double>(l); }
|
||||
constexpr auto operator"" q_ly(unsigned long long l) { return si::length<light_year, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ly(long double l) { return si::length<light_year, long double>(l); }
|
||||
|
||||
constexpr auto operator"" pc(unsigned long long l) { return si::length<parsec, std::int64_t>(l); }
|
||||
constexpr auto operator"" pc(long double l) { return si::length<parsec, long double>(l); }
|
||||
constexpr auto operator"" q_pc(unsigned long long l) { return si::length<parsec, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_pc(long double l) { return si::length<parsec, long double>(l); }
|
||||
|
||||
constexpr auto operator"" angstrom(unsigned long long l) { return si::length<angstrom, std::int64_t>(l); }
|
||||
constexpr auto operator"" angstrom(long double l) { return si::length<angstrom, long double>(l); }
|
||||
constexpr auto operator"" q_angstrom(unsigned long long l) { return si::length<angstrom, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_angstrom(long double l) { return si::length<angstrom, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -34,11 +34,11 @@ struct rod : named_scaled_unit<rod, "rd", no_prefix, ratio<1, 4>, chain> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
constexpr auto operator"" ch(unsigned long long l) { return si::length<chain, std::int64_t>(l); }
|
||||
constexpr auto operator"" ch(long double l) { return si::length<chain, long double>(l); }
|
||||
constexpr auto operator"" q_ch(unsigned long long l) { return si::length<chain, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ch(long double l) { return si::length<chain, long double>(l); }
|
||||
|
||||
constexpr auto operator"" rd(unsigned long long l) { return si::length<rod, std::int64_t>(l); }
|
||||
constexpr auto operator"" rd(long double l) { return si::length<rod, long double>(l); }
|
||||
constexpr auto operator"" q_rd(unsigned long long l) { return si::length<rod, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_rd(long double l) { return si::length<rod, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -32,8 +32,8 @@ struct square_foot : deduced_unit<square_foot, si::dim_area, international::foot
|
||||
inline namespace literals {
|
||||
|
||||
// ft2
|
||||
constexpr auto operator"" ft2(unsigned long long l) { return si::area<square_foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" ft2(long double l) { return si::area<square_foot, long double>(l); }
|
||||
constexpr auto operator"" q_ft2(unsigned long long l) { return si::area<square_foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft2(long double l) { return si::area<square_foot, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -61,36 +61,36 @@ using mil = thou;
|
||||
inline namespace literals {
|
||||
|
||||
// yd
|
||||
constexpr auto operator"" yd(unsigned long long l) { return si::length<yard, std::int64_t>(l); }
|
||||
constexpr auto operator"" yd(long double l) { return si::length<yard, long double>(l); }
|
||||
constexpr auto operator"" q_yd(unsigned long long l) { return si::length<yard, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_yd(long double l) { return si::length<yard, long double>(l); }
|
||||
|
||||
// ft
|
||||
constexpr auto operator"" ft(unsigned long long l) { return si::length<foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" ft(long double l) { return si::length<foot, long double>(l); }
|
||||
constexpr auto operator"" q_ft(unsigned long long l) { return si::length<foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft(long double l) { return si::length<foot, long double>(l); }
|
||||
|
||||
// fathom
|
||||
constexpr auto operator"" fathom(unsigned long long l) { return si::length<fathom, std::int64_t>(l); }
|
||||
constexpr auto operator"" fathom(long double l) { return si::length<fathom, long double>(l); }
|
||||
constexpr auto operator"" q_fathom(unsigned long long l) { return si::length<fathom, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_fathom(long double l) { return si::length<fathom, long double>(l); }
|
||||
|
||||
// in
|
||||
constexpr auto operator"" in(unsigned long long l) { return si::length<inch, std::int64_t>(l); }
|
||||
constexpr auto operator"" in(long double l) { return si::length<inch, long double>(l); }
|
||||
constexpr auto operator"" q_in(unsigned long long l) { return si::length<inch, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_in(long double l) { return si::length<inch, long double>(l); }
|
||||
|
||||
// mi
|
||||
constexpr auto operator"" mi(unsigned long long l) { return si::length<mile, std::int64_t>(l); }
|
||||
constexpr auto operator"" mi(long double l) { return si::length<mile, long double>(l); }
|
||||
constexpr auto operator"" q_mi(unsigned long long l) { return si::length<mile, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mi(long double l) { return si::length<mile, long double>(l); }
|
||||
|
||||
// mi_naut
|
||||
constexpr auto operator"" naut_mi(unsigned long long l) { return si::length<nautical_mile, std::int64_t>(l); }
|
||||
constexpr auto operator"" naut_mi(long double l) { return si::length<nautical_mile, long double>(l); }
|
||||
constexpr auto operator"" q_naut_mi(unsigned long long l) { return si::length<nautical_mile, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_naut_mi(long double l) { return si::length<nautical_mile, long double>(l); }
|
||||
|
||||
// thou
|
||||
constexpr auto operator"" thou(unsigned long long l) { return si::length<thou, std::int64_t>(l); }
|
||||
constexpr auto operator"" thou(long double l) { return si::length<thou, long double>(l); }
|
||||
constexpr auto operator"" q_thou(unsigned long long l) { return si::length<thou, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_thou(long double l) { return si::length<thou, long double>(l); }
|
||||
|
||||
// mil
|
||||
constexpr auto operator"" mil(unsigned long long l) { return si::length<mil, std::int64_t>(l); }
|
||||
constexpr auto operator"" mil(long double l) { return si::length<mil, long double>(l); }
|
||||
constexpr auto operator"" q_mil(unsigned long long l) { return si::length<mil, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mil(long double l) { return si::length<mil, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -32,8 +32,8 @@ struct mile_per_hour : deduced_unit<mile_per_hour, si::dim_velocity, internation
|
||||
inline namespace literals {
|
||||
|
||||
// mph
|
||||
constexpr auto operator"" mph(unsigned long long l) { return si::velocity<mile_per_hour, std::int64_t>(l); }
|
||||
constexpr auto operator"" mph(long double l) { return si::velocity<mile_per_hour, long double>(l); }
|
||||
constexpr auto operator"" q_mph(unsigned long long l) { return si::velocity<mile_per_hour, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mph(long double l) { return si::velocity<mile_per_hour, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -32,8 +32,8 @@ struct cubic_foot : deduced_unit<cubic_foot, si::dim_volume, international::foot
|
||||
inline namespace literals {
|
||||
|
||||
// ft3
|
||||
constexpr auto operator""ft3(unsigned long long l) { return si::volume<cubic_foot, std::int64_t>(l); }
|
||||
constexpr auto operator""ft3(long double l) { return si::volume<cubic_foot, long double>(l); }
|
||||
constexpr auto operator"" q_ft3(unsigned long long l) { return si::volume<cubic_foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft3(long double l) { return si::volume<cubic_foot, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -37,8 +37,8 @@ using acceleration = quantity<dim_acceleration, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// mps2
|
||||
constexpr auto operator""mps2(unsigned long long l) { return acceleration<metre_per_second_sq, std::int64_t>(l); }
|
||||
constexpr auto operator""mps2(long double l) { return acceleration<metre_per_second_sq, long double>(l); }
|
||||
constexpr auto operator"" q_mps2(unsigned long long l) { return acceleration<metre_per_second_sq, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mps2(long double l) { return acceleration<metre_per_second_sq, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -44,28 +44,28 @@ using area = quantity<dim_area, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// m2
|
||||
constexpr auto operator"" m2(unsigned long long l) { return area<square_metre, std::int64_t>(l); }
|
||||
constexpr auto operator"" m2(long double l) { return area<square_metre, long double>(l); }
|
||||
constexpr auto operator"" q_m2(unsigned long long l) { return area<square_metre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_m2(long double l) { return area<square_metre, long double>(l); }
|
||||
|
||||
// mm2
|
||||
constexpr auto operator"" mm2(unsigned long long l) { return area<square_millimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" mm2(long double l) { return area<square_millimetre, long double>(l); }
|
||||
constexpr auto operator"" q_mm2(unsigned long long l) { return area<square_millimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mm2(long double l) { return area<square_millimetre, long double>(l); }
|
||||
|
||||
// cm2
|
||||
constexpr auto operator"" cm2(unsigned long long l) { return area<square_centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" cm2(long double l) { return area<square_centimetre, long double>(l); }
|
||||
constexpr auto operator"" q_cm2(unsigned long long l) { return area<square_centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_cm2(long double l) { return area<square_centimetre, long double>(l); }
|
||||
|
||||
// fm2
|
||||
constexpr auto operator"" fm2(unsigned long long l) { return area<square_femtometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" fm2(long double l) { return area<square_femtometre, long double>(l); }
|
||||
constexpr auto operator"" q_fm2(unsigned long long l) { return area<square_femtometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_fm2(long double l) { return area<square_femtometre, long double>(l); }
|
||||
|
||||
// km2
|
||||
constexpr auto operator"" km2(unsigned long long l) { return area<square_kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" km2(long double l) { return area<square_kilometre, long double>(l); }
|
||||
constexpr auto operator"" q_km2(unsigned long long l) { return area<square_kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_km2(long double l) { return area<square_kilometre, long double>(l); }
|
||||
|
||||
// ha
|
||||
constexpr auto operator"" ha(unsigned long long l) { return area<hectare, std::int64_t>(l); }
|
||||
constexpr auto operator"" ha(long double l) { return area<hectare, long double>(l); }
|
||||
constexpr auto operator"" q_ha(unsigned long long l) { return area<hectare, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ha(long double l) { return area<hectare, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -45,20 +45,20 @@ using capacitance = quantity<dim_capacitance, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// F
|
||||
constexpr auto operator""F(unsigned long long l) { return capacitance<farad, std::int64_t>(l); }
|
||||
constexpr auto operator""_F(long double l) { return capacitance<farad, long double>(l); }
|
||||
constexpr auto operator"" q_F(unsigned long long l) { return capacitance<farad, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_F(long double l) { return capacitance<farad, long double>(l); }
|
||||
|
||||
constexpr auto operator""mF(unsigned long long l) { return capacitance<millifarad, std::int64_t>(l); }
|
||||
constexpr auto operator""mF(long double l) { return capacitance<millifarad, long double>(l); }
|
||||
constexpr auto operator"" q_mF(unsigned long long l) { return capacitance<millifarad, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mF(long double l) { return capacitance<millifarad, long double>(l); }
|
||||
|
||||
constexpr auto operator""uF(unsigned long long l) { return capacitance<microfarad, std::int64_t>(l); }
|
||||
constexpr auto operator""uF(long double l) { return capacitance<microfarad, long double>(l); }
|
||||
constexpr auto operator"" q_uF(unsigned long long l) { return capacitance<microfarad, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_uF(long double l) { return capacitance<microfarad, long double>(l); }
|
||||
|
||||
constexpr auto operator""nF(unsigned long long l) { return capacitance<nanofarad, std::int64_t>(l); }
|
||||
constexpr auto operator""nF(long double l) { return capacitance<nanofarad, long double>(l); }
|
||||
constexpr auto operator"" q_nF(unsigned long long l) { return capacitance<nanofarad, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_nF(long double l) { return capacitance<nanofarad, long double>(l); }
|
||||
|
||||
constexpr auto operator""pF(unsigned long long l) { return capacitance<picofarad, std::int64_t>(l); }
|
||||
constexpr auto operator""pF(long double l) { return capacitance<picofarad, long double>(l); }
|
||||
constexpr auto operator"" q_pF(unsigned long long l) { return capacitance<picofarad, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_pF(long double l) { return capacitance<picofarad, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -38,8 +38,8 @@ using current = quantity<dim_electric_current, U, Rep>;
|
||||
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); }
|
||||
constexpr auto operator"" q_A(unsigned long long l) { return current<ampere, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_A(long double l) { return current<ampere, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -39,8 +39,8 @@ using density = quantity<dim_density, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
constexpr auto operator"" kgpm3(unsigned long long l) { return density<kilogram_per_metre_cub, std::int64_t>(l); }
|
||||
constexpr auto operator"" kgpm3(long double l) { return density<kilogram_per_metre_cub, long double>(l); }
|
||||
constexpr auto operator"" q_kgpm3(unsigned long long l) { return density<kilogram_per_metre_cub, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_kgpm3(long double l) { return density<kilogram_per_metre_cub, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -39,8 +39,8 @@ using electric_charge = quantity<dim_electric_charge, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// C
|
||||
constexpr auto operator""C(unsigned long long l) { return electric_charge<coulomb, std::int64_t>(l); }
|
||||
constexpr auto operator""C(long double l) { return electric_charge<coulomb, long double>(l); }
|
||||
constexpr auto operator"" q_C(unsigned long long l) { return electric_charge<coulomb, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_C(long double l) { return electric_charge<coulomb, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -46,32 +46,32 @@ using energy = quantity<dim_energy, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// J
|
||||
constexpr auto operator""_J(unsigned long long l) { return energy<joule, std::int64_t>(l); }
|
||||
constexpr auto operator""_J(long double l) { return energy<joule, long double>(l); }
|
||||
constexpr auto operator"" q_J(unsigned long long l) { return energy<joule, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_J(long double l) { return energy<joule, long double>(l); }
|
||||
|
||||
// mJ
|
||||
constexpr auto operator""mJ(unsigned long long l) { return energy<millijoule, std::int64_t>(l); }
|
||||
constexpr auto operator""mJ(long double l) { return energy<millijoule, long double>(l); }
|
||||
constexpr auto operator"" q_mJ(unsigned long long l) { return energy<millijoule, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mJ(long double l) { return energy<millijoule, long double>(l); }
|
||||
|
||||
// kJ
|
||||
constexpr auto operator""kJ(unsigned long long l) { return energy<kilojoule, std::int64_t>(l); }
|
||||
constexpr auto operator""kJ(long double l) { return energy<kilojoule, long double>(l); }
|
||||
constexpr auto operator"" q_kJ(unsigned long long l) { return energy<kilojoule, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_kJ(long double l) { return energy<kilojoule, long double>(l); }
|
||||
|
||||
// MJ
|
||||
constexpr auto operator""MJ(unsigned long long l) { return energy<megajoule, std::int64_t>(l); }
|
||||
constexpr auto operator""MJ(long double l) { return energy<megajoule, long double>(l); }
|
||||
constexpr auto operator"" q_MJ(unsigned long long l) { return energy<megajoule, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_MJ(long double l) { return energy<megajoule, long double>(l); }
|
||||
|
||||
// GJ
|
||||
constexpr auto operator""GJ(unsigned long long l) { return energy<gigajoule, std::int64_t>(l); }
|
||||
constexpr auto operator""GJ(long double l) { return energy<gigajoule, long double>(l); }
|
||||
constexpr auto operator"" q_GJ(unsigned long long l) { return energy<gigajoule, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_GJ(long double l) { return energy<gigajoule, long double>(l); }
|
||||
|
||||
// eV
|
||||
constexpr auto operator""eV(unsigned long long l) { return energy<electronvolt, std::int64_t>(l); }
|
||||
constexpr auto operator""eV(long double l) { return energy<electronvolt, long double>(l); }
|
||||
constexpr auto operator"" q_eV(unsigned long long l) { return energy<electronvolt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_eV(long double l) { return energy<electronvolt, long double>(l); }
|
||||
|
||||
// GeV
|
||||
constexpr auto operator""GeV(unsigned long long l) { return energy<gigaelectronvolt, std::int64_t>(l); }
|
||||
constexpr auto operator""GeV(long double l) { return energy<gigaelectronvolt, long double>(l); }
|
||||
constexpr auto operator"" q_GeV(unsigned long long l) { return energy<gigaelectronvolt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_GeV(long double l) { return energy<gigaelectronvolt, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -40,8 +40,8 @@ using force = quantity<dim_force, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// N
|
||||
constexpr auto operator""N(unsigned long long l) { return force<newton, std::int64_t>(l); }
|
||||
constexpr auto operator""N(long double l) { return force<newton, long double>(l); }
|
||||
constexpr auto operator"" q_N(unsigned long long l) { return force<newton, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_N(long double l) { return force<newton, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -43,28 +43,28 @@ using frequency = quantity<dim_frequency, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// Hz
|
||||
constexpr auto operator"" Hz(unsigned long long l) { return frequency<hertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" Hz(long double l) { return frequency<hertz, long double>(l); }
|
||||
constexpr auto operator"" q_Hz(unsigned long long l) { return frequency<hertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Hz(long double l) { return frequency<hertz, long double>(l); }
|
||||
|
||||
// mHz
|
||||
constexpr auto operator"" mHz(unsigned long long l) { return frequency<millihertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" mHz(long double l) { return frequency<millihertz, long double>(l); }
|
||||
constexpr auto operator"" q_mHz(unsigned long long l) { return frequency<millihertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mHz(long double l) { return frequency<millihertz, long double>(l); }
|
||||
|
||||
// kHz
|
||||
constexpr auto operator"" kHz(unsigned long long l) { return frequency<kilohertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" kHz(long double l) { return frequency<kilohertz, long double>(l); }
|
||||
constexpr auto operator"" q_kHz(unsigned long long l) { return frequency<kilohertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_kHz(long double l) { return frequency<kilohertz, long double>(l); }
|
||||
|
||||
// MHz
|
||||
constexpr auto operator"" MHz(unsigned long long l) { return frequency<megahertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" MHz(long double l) { return frequency<megahertz, long double>(l); }
|
||||
constexpr auto operator"" q_MHz(unsigned long long l) { return frequency<megahertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_MHz(long double l) { return frequency<megahertz, long double>(l); }
|
||||
|
||||
// GHz
|
||||
constexpr auto operator"" GHz(unsigned long long l) { return frequency<gigahertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" GHz(long double l) { return frequency<gigahertz, long double>(l); }
|
||||
constexpr auto operator"" q_GHz(unsigned long long l) { return frequency<gigahertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_GHz(long double l) { return frequency<gigahertz, long double>(l); }
|
||||
|
||||
// THz
|
||||
constexpr auto operator"" THz(unsigned long long l) { return frequency<terahertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" THz(long double l) { return frequency<terahertz, long double>(l); }
|
||||
constexpr auto operator"" q_THz(unsigned long long l) { return frequency<terahertz, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_THz(long double l) { return frequency<terahertz, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -46,36 +46,36 @@ using length = quantity<dim_length, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// m
|
||||
constexpr auto operator"" m(unsigned long long l) { return length<metre, std::int64_t>(l); }
|
||||
constexpr auto operator"" m(long double l) { return length<metre, long double>(l); }
|
||||
constexpr auto operator"" q_m(unsigned long long l) { return length<metre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_m(long double l) { return length<metre, long double>(l); }
|
||||
|
||||
// fm
|
||||
constexpr auto operator"" fm(unsigned long long l) { return length<femtometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" fm(long double l) { return length<femtometre, long double>(l); }
|
||||
constexpr auto operator"" q_fm(unsigned long long l) { return length<femtometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_fm(long double l) { return length<femtometre, long double>(l); }
|
||||
|
||||
// mm
|
||||
constexpr auto operator"" mm(unsigned long long l) { return length<millimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" mm(long double l) { return length<millimetre, long double>(l); }
|
||||
constexpr auto operator"" q_mm(unsigned long long l) { return length<millimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mm(long double l) { return length<millimetre, long double>(l); }
|
||||
|
||||
// cm
|
||||
constexpr auto operator"" cm(unsigned long long l) { return length<centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" cm(long double l) { return length<centimetre, long double>(l); }
|
||||
constexpr auto operator"" q_cm(unsigned long long l) { return length<centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_cm(long double l) { return length<centimetre, long double>(l); }
|
||||
|
||||
// dm
|
||||
constexpr auto operator"" dm(unsigned long long l) { return length<decimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" dm(long double l) { return length<decimetre, long double>(l); }
|
||||
constexpr auto operator"" q_dm(unsigned long long l) { return length<decimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_dm(long double l) { return length<decimetre, long double>(l); }
|
||||
|
||||
// hm
|
||||
constexpr auto operator"" hm(unsigned long long l) { return length<hectometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" hm(long double l) { return length<hectometre, long double>(l); }
|
||||
constexpr auto operator"" q_hm(unsigned long long l) { return length<hectometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_hm(long double l) { return length<hectometre, long double>(l); }
|
||||
|
||||
// km
|
||||
constexpr auto operator"" km(unsigned long long l) { return length<kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" km(long double l) { return length<kilometre, long double>(l); }
|
||||
constexpr auto operator"" q_km(unsigned long long l) { return length<kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_km(long double l) { return length<kilometre, long double>(l); }
|
||||
|
||||
// au
|
||||
constexpr auto operator"" au(unsigned long long l) { return length<astronomical_unit, std::int64_t>(l); }
|
||||
constexpr auto operator"" au(long double l) { return length<astronomical_unit, long double>(l); }
|
||||
constexpr auto operator"" q_au(unsigned long long l) { return length<astronomical_unit, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_au(long double l) { return length<astronomical_unit, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -38,8 +38,8 @@ using luminous_intensity = quantity<dim_luminous_intensity, U, Rep>;
|
||||
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); }
|
||||
constexpr auto operator"" q_cd(unsigned long long l) { return luminous_intensity<candela, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_cd(long double l) { return luminous_intensity<candela, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -42,20 +42,20 @@ using mass = quantity<dim_mass, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// g
|
||||
constexpr auto operator""g(unsigned long long l) { return mass<gram, std::int64_t>(l); }
|
||||
constexpr auto operator""g(long double l) { return mass<gram, long double>(l); }
|
||||
constexpr auto operator"" q_g(unsigned long long l) { return mass<gram, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_g(long double l) { return mass<gram, long double>(l); }
|
||||
|
||||
// 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); }
|
||||
constexpr auto operator"" q_kg(unsigned long long l) { return mass<kilogram, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_kg(long double l) { return mass<kilogram, long double>(l); }
|
||||
|
||||
// t
|
||||
constexpr auto operator""t(unsigned long long l) { return mass<tonne, std::int64_t>(l); }
|
||||
constexpr auto operator""t(long double l) { return mass<tonne, long double>(l); }
|
||||
constexpr auto operator"" q_t(unsigned long long l) { return mass<tonne, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_t(long double l) { return mass<tonne, long double>(l); }
|
||||
|
||||
// Da
|
||||
constexpr auto operator""Da(unsigned long long l) { return mass<dalton, std::int64_t>(l); }
|
||||
constexpr auto operator""Da(long double l) { return mass<dalton, long double>(l); }
|
||||
constexpr auto operator"" q_Da(unsigned long long l) { return mass<dalton, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Da(long double l) { return mass<dalton, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -43,24 +43,24 @@ using power = quantity<dim_power, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// W
|
||||
constexpr auto operator""W(unsigned long long l) { return power<watt, std::int64_t>(l); }
|
||||
constexpr auto operator""_W(long double l) { return power<watt, long double>(l); }
|
||||
constexpr auto operator"" q_W(unsigned long long l) { return power<watt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_W(long double l) { return power<watt, long double>(l); }
|
||||
|
||||
// mW
|
||||
constexpr auto operator""mW(unsigned long long l) { return power<milliwatt, std::int64_t>(l); }
|
||||
constexpr auto operator""mW(long double l) { return power<milliwatt, long double>(l); }
|
||||
constexpr auto operator"" q_mW(unsigned long long l) { return power<milliwatt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mW(long double l) { return power<milliwatt, long double>(l); }
|
||||
|
||||
// kW
|
||||
constexpr auto operator""kW(unsigned long long l) { return power<kilowatt, std::int64_t>(l); }
|
||||
constexpr auto operator""kW(long double l) { return power<kilowatt, long double>(l); }
|
||||
constexpr auto operator"" q_kW(unsigned long long l) { return power<kilowatt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_kW(long double l) { return power<kilowatt, long double>(l); }
|
||||
|
||||
// MW
|
||||
constexpr auto operator""MW(unsigned long long l) { return power<megawatt, std::int64_t>(l); }
|
||||
constexpr auto operator""MW(long double l) { return power<megawatt, long double>(l); }
|
||||
constexpr auto operator"" q_MW(unsigned long long l) { return power<megawatt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_MW(long double l) { return power<megawatt, long double>(l); }
|
||||
|
||||
// GW
|
||||
constexpr auto operator""GW(unsigned long long l) { return power<gigawatt, std::int64_t>(l); }
|
||||
constexpr auto operator""GW(long double l) { return power<gigawatt, long double>(l); }
|
||||
constexpr auto operator"" q_GW(unsigned long long l) { return power<gigawatt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_GW(long double l) { return power<gigawatt, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -40,8 +40,8 @@ using pressure = quantity<dim_pressure, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// Pa
|
||||
constexpr auto operator""Pa(unsigned long long l) { return pressure<pascal, std::int64_t>(l); }
|
||||
constexpr auto operator""Pa(long double l) { return pressure<pascal, long double>(l); }
|
||||
constexpr auto operator"" q_Pa(unsigned long long l) { return pressure<pascal, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Pa(long double l) { return pressure<pascal, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -43,20 +43,20 @@ using resistance = quantity<dim_resistance, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// R
|
||||
constexpr auto operator""_R(unsigned long long l) { return resistance<ohm, std::int64_t>(l); }
|
||||
constexpr auto operator""_R(long double l) { return resistance<ohm, long double>(l); }
|
||||
constexpr auto operator"" q_R(unsigned long long l) { return resistance<ohm, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_R(long double l) { return resistance<ohm, long double>(l); }
|
||||
|
||||
// mR
|
||||
constexpr auto operator""mR(unsigned long long l) { return resistance<milliohm, std::int64_t>(l); }
|
||||
constexpr auto operator""mR(long double l) { return resistance<milliohm, long double>(l); }
|
||||
constexpr auto operator"" q_mR(unsigned long long l) { return resistance<milliohm, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mR(long double l) { return resistance<milliohm, long double>(l); }
|
||||
|
||||
// kR
|
||||
constexpr auto operator""kR(unsigned long long l) { return resistance<kiloohm, std::int64_t>(l); }
|
||||
constexpr auto operator""kR(long double l) { return resistance<kiloohm, long double>(l); }
|
||||
constexpr auto operator"" q_kR(unsigned long long l) { return resistance<kiloohm, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_kR(long double l) { return resistance<kiloohm, long double>(l); }
|
||||
|
||||
// MR
|
||||
constexpr auto operator""MR(unsigned long long l) { return resistance<megaohm, std::int64_t>(l); }
|
||||
constexpr auto operator""MR(long double l) { return resistance<megaohm, long double>(l); }
|
||||
constexpr auto operator"" q_MR(unsigned long long l) { return resistance<megaohm, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_MR(long double l) { return resistance<megaohm, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -38,8 +38,8 @@ using substance = quantity<dim_substance, U, Rep>;
|
||||
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); }
|
||||
constexpr auto operator"" q_mol(unsigned long long l) { return substance<mole, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mol(long double l) { return substance<mole, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -38,8 +38,8 @@ using surface_tension = quantity<dim_surface_tension, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// Nm
|
||||
constexpr auto operator""Npm(unsigned long long l) { return surface_tension<newton_per_metre, std::int64_t>(l); }
|
||||
constexpr auto operator""Npm(long double l) { return surface_tension<newton_per_metre, long double>(l); }
|
||||
constexpr auto operator"" q_Npm(unsigned long long l) { return surface_tension<newton_per_metre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Npm(long double l) { return surface_tension<newton_per_metre, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -37,8 +37,8 @@ using temperature = quantity<dim_thermodynamic_temperature, U, Rep>;
|
||||
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); } // TODO: conflicts with gcc GNU extension
|
||||
constexpr auto operator"" q_K(unsigned long long l) { return temperature<kelvin, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_K(long double l) { return temperature<kelvin, long double>(l); } // TODO: conflicts with gcc GNU extension
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -44,32 +44,32 @@ using time = quantity<dim_time, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// ns
|
||||
constexpr auto operator""ns(unsigned long long l) { return time<nanosecond, std::int64_t>(l); }
|
||||
constexpr auto operator""ns(long double l) { return time<nanosecond, long double>(l); }
|
||||
constexpr auto operator"" q_ns(unsigned long long l) { return time<nanosecond, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ns(long double l) { return time<nanosecond, long double>(l); }
|
||||
|
||||
// us
|
||||
constexpr auto operator""us(unsigned long long l) { return time<microsecond, std::int64_t>(l); }
|
||||
constexpr auto operator""us(long double l) { return time<microsecond, long double>(l); }
|
||||
constexpr auto operator"" q_us(unsigned long long l) { return time<microsecond, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_us(long double l) { return time<microsecond, long double>(l); }
|
||||
|
||||
// ms
|
||||
constexpr auto operator""ms(unsigned long long l) { return time<millisecond, std::int64_t>(l); }
|
||||
constexpr auto operator""ms(long double l) { return time<millisecond, long double>(l); }
|
||||
constexpr auto operator"" q_ms(unsigned long long l) { return time<millisecond, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ms(long double l) { return time<millisecond, long double>(l); }
|
||||
|
||||
// s
|
||||
constexpr auto operator""s(unsigned long long l) { return time<second, std::int64_t>(l); }
|
||||
constexpr auto operator""s(long double l) { return time<second, long double>(l); }
|
||||
constexpr auto operator"" q_s(unsigned long long l) { return time<second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_s(long double l) { return time<second, long double>(l); }
|
||||
|
||||
// min
|
||||
constexpr auto operator""min(unsigned long long l) { return time<minute, std::int64_t>(l); }
|
||||
constexpr auto operator""min(long double l) { return time<minute, long double>(l); }
|
||||
constexpr auto operator"" q_min(unsigned long long l) { return time<minute, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_min(long double l) { return time<minute, long double>(l); }
|
||||
|
||||
// h
|
||||
constexpr auto operator""h(unsigned long long l) { return time<hour, std::int64_t>(l); }
|
||||
constexpr auto operator""h(long double l) { return time<hour, long double>(l); }
|
||||
constexpr auto operator"" q_h(unsigned long long l) { return time<hour, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_h(long double l) { return time<hour, long double>(l); }
|
||||
|
||||
// d
|
||||
constexpr auto operator""_d(unsigned long long l) { return time<day, std::int64_t>(l); }
|
||||
constexpr auto operator""_d(long double l) { return time<day, long double>(l); }
|
||||
constexpr auto operator"" q_d(unsigned long long l) { return time<day, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_d(long double l) { return time<day, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -40,12 +40,12 @@ using velocity = quantity<dim_velocity, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// mps
|
||||
constexpr auto operator"" mps(unsigned long long l) { return velocity<metre_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" mps(long double l) { return velocity<metre_per_second, long double>(l); }
|
||||
constexpr auto operator"" q_mps(unsigned long long l) { return velocity<metre_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mps(long double l) { return velocity<metre_per_second, long double>(l); }
|
||||
|
||||
// kmph
|
||||
constexpr auto operator"" kmph(unsigned long long l) { return velocity<kilometre_per_hour, std::int64_t>(l); }
|
||||
constexpr auto operator"" kmph(long double l) { return velocity<kilometre_per_hour, long double>(l); }
|
||||
constexpr auto operator"" q_kmph(unsigned long long l) { return velocity<kilometre_per_hour, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_kmph(long double l) { return velocity<kilometre_per_hour, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -44,20 +44,20 @@ using voltage = quantity<dim_voltage, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// V
|
||||
constexpr auto operator""V(unsigned long long l) { return voltage<volt, std::int64_t>(l); }
|
||||
constexpr auto operator""V(long double l) { return voltage<volt, long double>(l); }
|
||||
constexpr auto operator"" q_V(unsigned long long l) { return voltage<volt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_V(long double l) { return voltage<volt, long double>(l); }
|
||||
|
||||
constexpr auto operator""mV(unsigned long long l) { return voltage<millivolt, std::int64_t>(l); }
|
||||
constexpr auto operator""mV(long double l) { return voltage<millivolt, long double>(l); }
|
||||
constexpr auto operator"" q_mV(unsigned long long l) { return voltage<millivolt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mV(long double l) { return voltage<millivolt, long double>(l); }
|
||||
|
||||
constexpr auto operator""uV(unsigned long long l) { return voltage<microvolt, std::int64_t>(l); }
|
||||
constexpr auto operator""uV(long double l) { return voltage<microvolt, long double>(l); }
|
||||
constexpr auto operator"" q_uV(unsigned long long l) { return voltage<microvolt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_uV(long double l) { return voltage<microvolt, long double>(l); }
|
||||
|
||||
constexpr auto operator""nV(unsigned long long l) { return voltage<nanovolt, std::int64_t>(l); }
|
||||
constexpr auto operator""nV(long double l) { return voltage<nanovolt, long double>(l); }
|
||||
constexpr auto operator"" q_nV(unsigned long long l) { return voltage<nanovolt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_nV(long double l) { return voltage<nanovolt, long double>(l); }
|
||||
|
||||
constexpr auto operator""pV(unsigned long long l) { return voltage<picovolt, std::int64_t>(l); }
|
||||
constexpr auto operator""pV(long double l) { return voltage<picovolt, long double>(l); }
|
||||
constexpr auto operator"" q_pV(unsigned long long l) { return voltage<picovolt, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_pV(long double l) { return voltage<picovolt, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -44,24 +44,24 @@ using volume = quantity<dim_volume, U, Rep>;
|
||||
inline namespace literals {
|
||||
|
||||
// mm3
|
||||
constexpr auto operator""mm3(unsigned long long l) { return volume<cubic_millimetre, std::int64_t>(l); }
|
||||
constexpr auto operator""mm3(long double l) { return volume<cubic_millimetre, long double>(l); }
|
||||
constexpr auto operator"" q_mm3(unsigned long long l) { return volume<cubic_millimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mm3(long double l) { return volume<cubic_millimetre, long double>(l); }
|
||||
|
||||
// cm3
|
||||
constexpr auto operator""cm3(unsigned long long l) { return volume<cubic_centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator""cm3(long double l) { return volume<cubic_centimetre, long double>(l); }
|
||||
constexpr auto operator"" q_cm3(unsigned long long l) { return volume<cubic_centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_cm3(long double l) { return volume<cubic_centimetre, long double>(l); }
|
||||
|
||||
// m3
|
||||
constexpr auto operator""m3(unsigned long long l) { return volume<cubic_metre, std::int64_t>(l); }
|
||||
constexpr auto operator""m3(long double l) { return volume<cubic_metre, long double>(l); }
|
||||
constexpr auto operator"" q_m3(unsigned long long l) { return volume<cubic_metre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_m3(long double l) { return volume<cubic_metre, long double>(l); }
|
||||
|
||||
// km3
|
||||
constexpr auto operator""km3(unsigned long long l) { return volume<cubic_kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator""km3(long double l) { return volume<cubic_kilometre, long double>(l); }
|
||||
constexpr auto operator"" q_km3(unsigned long long l) { return volume<cubic_kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_km3(long double l) { return volume<cubic_kilometre, long double>(l); }
|
||||
|
||||
// l
|
||||
constexpr auto operator""_l(unsigned long long l) { return volume<litre, std::int64_t>(l); }
|
||||
constexpr auto operator""_l(long double l) { return volume<litre, long double>(l); }
|
||||
constexpr auto operator"" q_l(unsigned long long l) { return volume<litre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_l(long double l) { return volume<litre, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -36,20 +36,20 @@ struct point_prn : named_scaled_unit<point_prn, "point(prn)", no_prefix, ratio<1
|
||||
inline namespace literals {
|
||||
|
||||
// pica comp
|
||||
constexpr auto operator"" pica_comp(unsigned long long l) { return si::length<pica_comp, std::int64_t>(l); }
|
||||
constexpr auto operator"" pica_comp(long double l) { return si::length<pica_comp, long double>(l); }
|
||||
constexpr auto operator"" q_pica_comp(unsigned long long l) { return si::length<pica_comp, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_pica_comp(long double l) { return si::length<pica_comp, long double>(l); }
|
||||
|
||||
// pica prn
|
||||
constexpr auto operator"" pica_prn(unsigned long long l) { return si::length<pica_prn, std::int64_t>(l); }
|
||||
constexpr auto operator"" pica_prn(long double l) { return si::length<pica_prn, long double>(l); }
|
||||
constexpr auto operator"" q_pica_prn(unsigned long long l) { return si::length<pica_prn, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_pica_prn(long double l) { return si::length<pica_prn, long double>(l); }
|
||||
|
||||
// point comp
|
||||
constexpr auto operator"" point_comp(unsigned long long l) { return si::length<point_comp, std::int64_t>(l); }
|
||||
constexpr auto operator"" point_comp(long double l) { return si::length<point_comp, long double>(l); }
|
||||
constexpr auto operator"" q_point_comp(unsigned long long l) { return si::length<point_comp, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_point_comp(long double l) { return si::length<point_comp, long double>(l); }
|
||||
|
||||
// point prn
|
||||
constexpr auto operator"" point_prn(unsigned long long l) { return si::length<point_prn, std::int64_t>(l); }
|
||||
constexpr auto operator"" point_prn(long double l) { return si::length<point_prn, long double>(l); }
|
||||
constexpr auto operator"" q_point_prn(unsigned long long l) { return si::length<point_prn, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_point_prn(long double l) { return si::length<point_prn, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -40,16 +40,16 @@ struct mile : named_scaled_unit<mile, "mi(us)", no_prefix, ratio<5280>, us::foot
|
||||
inline namespace literals {
|
||||
|
||||
// ft
|
||||
constexpr auto operator"" ft_us(unsigned long long l) { return si::length<units::us::foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" ft_us(long double l) { return si::length<units::us::foot, long double>(l); }
|
||||
constexpr auto operator"" q_ft_us(unsigned long long l) { return si::length<units::us::foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft_us(long double l) { return si::length<units::us::foot, long double>(l); }
|
||||
|
||||
// fathom
|
||||
constexpr auto operator"" fathom_us(unsigned long long l) { return si::length<units::us::fathom, std::int64_t>(l); }
|
||||
constexpr auto operator"" fathom_us(long double l) { return si::length<units::us::fathom, long double>(l); }
|
||||
constexpr auto operator"" q_fathom_us(unsigned long long l) { return si::length<units::us::fathom, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_fathom_us(long double l) { return si::length<units::us::fathom, long double>(l); }
|
||||
|
||||
// ft
|
||||
constexpr auto operator"" mi_us(unsigned long long l) { return si::length<units::us::mile, std::int64_t>(l); }
|
||||
constexpr auto operator"" mi_us(long double l) { return si::length<units::us::mile, long double>(l); }
|
||||
constexpr auto operator"" q_mi_us(unsigned long long l) { return si::length<units::us::mile, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mi_us(long double l) { return si::length<units::us::mile, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
|
@@ -157,7 +157,7 @@ struct cast_ratio<FromD, FromU, ToD, ToU> {
|
||||
*
|
||||
* This cast gets the target quantity type to cast to. For example:
|
||||
*
|
||||
* auto q1 = units::quantity_cast<units::si::time<units::si::second>>(1ms);
|
||||
* auto q1 = units::quantity_cast<units::si::time<units::si::second>>(1q_ms);
|
||||
*
|
||||
* @tparam To a target quantity type to cast to
|
||||
*/
|
||||
@@ -182,7 +182,7 @@ template<Quantity To, typename D, typename U, typename Rep>
|
||||
*
|
||||
* This cast gets only the target dimension to cast to. For example:
|
||||
*
|
||||
* auto q1 = units::quantity_cast<units::si::acceleration>(200Gal);
|
||||
* auto q1 = units::quantity_cast<units::si::acceleration>(200q_Gal);
|
||||
*
|
||||
* @tparam ToD a dimension type to use for a target quantity
|
||||
*/
|
||||
@@ -201,7 +201,7 @@ template<Dimension ToD, typename D, typename U, typename Rep>
|
||||
*
|
||||
* This cast gets only the target unit to cast to. For example:
|
||||
*
|
||||
* auto q1 = units::quantity_cast<units::si::second>(1ms);
|
||||
* auto q1 = units::quantity_cast<units::si::second>(1q_ms);
|
||||
*
|
||||
* @tparam ToU a unit type to use for a target quantity
|
||||
*/
|
||||
@@ -220,7 +220,7 @@ template<Unit ToU, typename D, typename U, typename Rep>
|
||||
*
|
||||
* This cast gets only representation to cast to. For example:
|
||||
*
|
||||
* auto q1 = units::quantity_cast<int>(1ms);
|
||||
* auto q1 = units::quantity_cast<int>(1q_ms);
|
||||
*
|
||||
* @tparam ToRep a representation type to use for a target quantity
|
||||
*/
|
||||
|
@@ -34,25 +34,25 @@ TEST_CASE("operator<< on a data quantity", "[text][ostream]")
|
||||
{
|
||||
SECTION("named unit")
|
||||
{
|
||||
stream << 64B;
|
||||
stream << 64q_B;
|
||||
REQUIRE(stream.str() == "64 B");
|
||||
}
|
||||
|
||||
SECTION("prefixed coherent unit")
|
||||
{
|
||||
stream << 256Kib;
|
||||
stream << 256q_Kib;
|
||||
REQUIRE(stream.str() == "256 Kib");
|
||||
}
|
||||
|
||||
SECTION("prefixed non-coherent unit")
|
||||
{
|
||||
stream << 1024KiB;
|
||||
stream << 1024q_KiB;
|
||||
REQUIRE(stream.str() == "1024 KiB");
|
||||
}
|
||||
|
||||
SECTION("other unit matching prefix")
|
||||
{
|
||||
stream << 8Kib * 8Kib / 2b;
|
||||
stream << 8q_Kib * 8q_Kib / 2q_b;
|
||||
REQUIRE(stream.str() == "32 Mib");
|
||||
}
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
{
|
||||
SECTION("integral representation")
|
||||
{
|
||||
const auto q = 60W;
|
||||
const auto q = 60q_W;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -67,7 +67,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("floating-point representation")
|
||||
{
|
||||
const auto q = 1023.5Pa;
|
||||
const auto q = 1023.5q_Pa;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -89,7 +89,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("quantity with a predefined prefixed unit")
|
||||
{
|
||||
const auto q = 125us;
|
||||
const auto q = 125q_us;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -159,7 +159,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
{
|
||||
SECTION("acceleration")
|
||||
{
|
||||
const auto q = 20m / 2s / 1s;
|
||||
const auto q = 20q_m / 2q_s / 1q_s;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -180,7 +180,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("volume")
|
||||
{
|
||||
const auto q = 2m * 1m * 1m;
|
||||
const auto q = 2q_m * 1q_m * 1q_m;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -201,7 +201,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("surface tension")
|
||||
{
|
||||
const auto q = 20N / 2m;
|
||||
const auto q = 20q_N / 2q_m;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -225,12 +225,12 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
{
|
||||
SECTION("velocity")
|
||||
{
|
||||
const auto q = 20km / 2h;
|
||||
const auto q = 20q_km / 2q_h;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
{
|
||||
CHECK(stream.str() == "10 km/h");
|
||||
CHECK(stream.str() == "10.q_km/h");
|
||||
}
|
||||
|
||||
SECTION("fmt with default format {} on a quantity")
|
||||
@@ -272,7 +272,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
{
|
||||
SECTION("unit::ratio as an SI prefix for a dimension with a special symbol")
|
||||
{
|
||||
const auto q = 4N * 2cm;
|
||||
const auto q = 4q_N * 2q_cm;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -293,7 +293,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("unit::ratio for a dimension without a special symbol")
|
||||
{
|
||||
const auto q = 2cm * 2m * 2m;
|
||||
const auto q = 2q_cm * 2q_m * 2q_m;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -314,7 +314,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("unit::ratio::num != 1 && unit::ratio::den == 1")
|
||||
{
|
||||
const auto q = 4 * 2min / (2s * 2s);
|
||||
const auto q = 4 * 2q_min / (2q_s * 2q_s);
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -335,7 +335,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("unit::ratio::num == 1 && unit::ratio::den != 1")
|
||||
{
|
||||
const auto q = 20_J / 2min;
|
||||
const auto q = 20q_J / 2q_min;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -356,7 +356,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("unit::ratio::num != 1 && unit::ratio::den != 1")
|
||||
{
|
||||
const auto q = 60kJ / 2min;
|
||||
const auto q = 60q_kJ / 2q_min;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -382,7 +382,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
{
|
||||
SECTION("SI base units")
|
||||
{
|
||||
const auto q = 2s * 2m * 2kg;
|
||||
const auto q = 2q_s * 2q_m * 2q_kg;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -403,7 +403,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("CGS base units")
|
||||
{
|
||||
const auto q = 2s * cgs::length<cgs::centimetre>(2) * cgs::mass<cgs::gram>(2);
|
||||
const auto q = 2q_s * cgs::length<cgs::centimetre>(2) * cgs::mass<cgs::gram>(2);
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -425,7 +425,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("unit::ratio as an SI prefix")
|
||||
{
|
||||
const auto q = 4km * 2s;
|
||||
const auto q = 4q_km * 2q_s;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -446,7 +446,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("unit::ratio::num != 1 && unit::ratio::den == 1")
|
||||
{
|
||||
const auto q = 4kg * 2min / (2s * 2s);
|
||||
const auto q = 4q_kg * 2q_min / (2q_s * 2q_s);
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -467,7 +467,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("unit::ratio::num == 1 && unit::ratio::den != 1")
|
||||
{
|
||||
const auto q = 20kg / 2min;
|
||||
const auto q = 20q_kg / 2q_min;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -488,7 +488,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("CGS base units")
|
||||
{
|
||||
const auto q = 2s * cgs::length<si::metre>(2) * cgs::mass<si::kilogram>(2);
|
||||
const auto q = 2q_s * cgs::length<si::metre>(2) * cgs::mass<si::kilogram>(2);
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -509,7 +509,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("unit::ratio::num != 1 && unit::ratio::den != 1")
|
||||
{
|
||||
const auto q = 60min / 2km;
|
||||
const auto q = 60q_min / 2q_km;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -530,7 +530,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("exp::num == 1 && exp::den == 1")
|
||||
{
|
||||
const auto q = 4m * 2s;
|
||||
const auto q = 4q_m * 2q_s;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -551,7 +551,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("exp::num == 2 && exp::den == 1 for positive exponent")
|
||||
{
|
||||
const auto q = 4m * 2s * 2s;
|
||||
const auto q = 4q_m * 2q_s * 2q_s;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -572,7 +572,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("exp::num == 2 && exp::den == 1 for negative exponent (first dimension)")
|
||||
{
|
||||
const auto q = 8s / 2m / 2m;
|
||||
const auto q = 8q_s / 2q_m / 2q_m;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -593,7 +593,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("exp::num == 2 && exp::den == 1 for negative exponent (not first dimension)")
|
||||
{
|
||||
const auto q = 8m / 2kg / 2kg;
|
||||
const auto q = 8q_m / 2q_kg / 2q_kg;
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -614,7 +614,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("fractional positive exponent")
|
||||
{
|
||||
const auto q = sqrt(9m);
|
||||
const auto q = sqrt(9q_m);
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -635,7 +635,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("fractional negative exponent")
|
||||
{
|
||||
const auto q = sqrt(9 / 1m);
|
||||
const auto q = sqrt(9 / 1q_m);
|
||||
stream << q;
|
||||
|
||||
SECTION("iostream")
|
||||
@@ -662,12 +662,12 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text]
|
||||
{
|
||||
SECTION("positive value")
|
||||
{
|
||||
CHECK(fmt::format("{:%Q}", 123kmph) == "123");
|
||||
CHECK(fmt::format("{:%Q}", 123q_kmph) == "123");
|
||||
}
|
||||
|
||||
SECTION("negative value")
|
||||
{
|
||||
CHECK(fmt::format("{:%Q}", 5m - 10m) == "-5");
|
||||
CHECK(fmt::format("{:%Q}", 5q_m - 10q_m) == "-5");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,12 +675,12 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text]
|
||||
{
|
||||
SECTION("positive value")
|
||||
{
|
||||
CHECK(fmt::format("{:%Q}", 221.km / 2h) == "110.5");
|
||||
CHECK(fmt::format("{:%Q}", 221.q_km / 2q_h) == "110.5");
|
||||
}
|
||||
|
||||
SECTION("negative value")
|
||||
{
|
||||
CHECK(fmt::format("{:%Q}", 3.14m - 10m) == "-6.86");
|
||||
CHECK(fmt::format("{:%Q}", 3.14q_m - 10q_m) == "-6.86");
|
||||
}
|
||||
|
||||
SECTION("nan")
|
||||
@@ -702,39 +702,39 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text]
|
||||
|
||||
TEST_CASE("format string with only %q should print quantity unit symbol only", "[text][fmt]")
|
||||
{
|
||||
CHECK(fmt::format("{:%q}", 123kmph) == "km/h");
|
||||
CHECK(fmt::format("{:%q}", 123q_kmph) == "km/h");
|
||||
}
|
||||
|
||||
TEST_CASE("%q an %Q can be put anywhere in a format string", "[text][fmt]")
|
||||
{
|
||||
SECTION("no space")
|
||||
{
|
||||
CHECK(fmt::format("{:%Q%q}", 123kmph) == "123km/h");
|
||||
CHECK(fmt::format("{:%Q%q}", 123q_kmph) == "123q_km/h");
|
||||
}
|
||||
|
||||
SECTION("separator")
|
||||
{
|
||||
CHECK(fmt::format("{:%Q###%q}", 123kmph) == "123###km/h");
|
||||
CHECK(fmt::format("{:%Q###%q}", 123q_kmph) == "123###km/h");
|
||||
}
|
||||
|
||||
SECTION("opposite order")
|
||||
{
|
||||
CHECK(fmt::format("{:%q %Q}", 123kmph) == "km/h 123");
|
||||
CHECK(fmt::format("{:%q %Q}", 123q_kmph) == "km/h 123");
|
||||
}
|
||||
|
||||
SECTION("tabulator")
|
||||
{
|
||||
CHECK(fmt::format("{:%Q%t%q}", 123kmph) == "123\tkm/h");
|
||||
CHECK(fmt::format("{:%Q%t%q}", 123q_kmph) == "123\tkm/h");
|
||||
}
|
||||
|
||||
SECTION("new line")
|
||||
{
|
||||
CHECK(fmt::format("{:%Q%n%q}", 123kmph) == "123\nkm/h");
|
||||
CHECK(fmt::format("{:%Q%n%q}", 123q_kmph) == "123\nkm/h");
|
||||
}
|
||||
|
||||
SECTION("% sign")
|
||||
{
|
||||
CHECK(fmt::format("{:%Q%% %q}", 123kmph) == "123% km/h");
|
||||
CHECK(fmt::format("{:%Q%% %q}", 123q_kmph) == "123% km/h");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -742,50 +742,50 @@ TEST_CASE("fill and align specification", "[text][fmt]")
|
||||
{
|
||||
SECTION("default format {} on a quantity")
|
||||
{
|
||||
CHECK(fmt::format("|{:0}|", 123m) == "|123 m|");
|
||||
CHECK(fmt::format("|{:10}|", 123m) == "| 123 m|");
|
||||
CHECK(fmt::format("|{:<10}|", 123m) == "|123 m |");
|
||||
CHECK(fmt::format("|{:>10}|", 123m) == "| 123 m|");
|
||||
CHECK(fmt::format("|{:^10}|", 123m) == "| 123 m |");
|
||||
CHECK(fmt::format("|{:*<10}|", 123m) == "|123 m*****|");
|
||||
CHECK(fmt::format("|{:*>10}|", 123m) == "|*****123 m|");
|
||||
CHECK(fmt::format("|{:*^10}|", 123m) == "|**123 m***|");
|
||||
CHECK(fmt::format("|{:0}|", 123q_m) == "|123 m|");
|
||||
CHECK(fmt::format("|{:10}|", 123q_m) == "| 123 m|");
|
||||
CHECK(fmt::format("|{:<10}|", 123q_m) == "|123 m |");
|
||||
CHECK(fmt::format("|{:>10}|", 123q_m) == "| 123 m|");
|
||||
CHECK(fmt::format("|{:^10}|", 123q_m) == "| 123 m |");
|
||||
CHECK(fmt::format("|{:*<10}|", 123q_m) == "|123 m*****|");
|
||||
CHECK(fmt::format("|{:*>10}|", 123q_m) == "|*****123 m|");
|
||||
CHECK(fmt::format("|{:*^10}|", 123q_m) == "|**123 m***|");
|
||||
}
|
||||
|
||||
SECTION("full format {:%Q %q} on a quantity")
|
||||
{
|
||||
CHECK(fmt::format("|{:0%Q%q}|", 123m) == "|123m|");
|
||||
CHECK(fmt::format("|{:10%Q%q}|", 123m) == "| 123m|");
|
||||
CHECK(fmt::format("|{:<10%Q%q}|", 123m) == "|123m |");
|
||||
CHECK(fmt::format("|{:>10%Q%q}|", 123m) == "| 123m|");
|
||||
CHECK(fmt::format("|{:^10%Q%q}|", 123m) == "| 123m |");
|
||||
CHECK(fmt::format("|{:*<10%Q%q}|", 123m) == "|123m******|");
|
||||
CHECK(fmt::format("|{:*>10%Q%q}|", 123m) == "|******123m|");
|
||||
CHECK(fmt::format("|{:*^10%Q%q}|", 123m) == "|***123m***|");
|
||||
CHECK(fmt::format("|{:0%Q%q}|", 123q_m) == "|123q_m|");
|
||||
CHECK(fmt::format("|{:10%Q%q}|", 123q_m) == "| 123q_m|");
|
||||
CHECK(fmt::format("|{:<10%Q%q}|", 123q_m) == "|123q_m |");
|
||||
CHECK(fmt::format("|{:>10%Q%q}|", 123q_m) == "| 123q_m|");
|
||||
CHECK(fmt::format("|{:^10%Q%q}|", 123q_m) == "| 123q_m |");
|
||||
CHECK(fmt::format("|{:*<10%Q%q}|", 123q_m) == "|123q_m******|");
|
||||
CHECK(fmt::format("|{:*>10%Q%q}|", 123q_m) == "|******123q_m|");
|
||||
CHECK(fmt::format("|{:*^10%Q%q}|", 123q_m) == "|***123q_m***|");
|
||||
}
|
||||
|
||||
SECTION("value only format {:%Q} on a quantity")
|
||||
{
|
||||
CHECK(fmt::format("|{:0%Q}|", 123m) == "|123|");
|
||||
CHECK(fmt::format("|{:10%Q}|", 123m) == "| 123|");
|
||||
CHECK(fmt::format("|{:<10%Q}|", 123m) == "|123 |");
|
||||
CHECK(fmt::format("|{:>10%Q}|", 123m) == "| 123|");
|
||||
CHECK(fmt::format("|{:^10%Q}|", 123m) == "| 123 |");
|
||||
CHECK(fmt::format("|{:*<10%Q}|", 123m) == "|123*******|");
|
||||
CHECK(fmt::format("|{:*>10%Q}|", 123m) == "|*******123|");
|
||||
CHECK(fmt::format("|{:*^10%Q}|", 123m) == "|***123****|");
|
||||
CHECK(fmt::format("|{:0%Q}|", 123q_m) == "|123|");
|
||||
CHECK(fmt::format("|{:10%Q}|", 123q_m) == "| 123|");
|
||||
CHECK(fmt::format("|{:<10%Q}|", 123q_m) == "|123 |");
|
||||
CHECK(fmt::format("|{:>10%Q}|", 123q_m) == "| 123|");
|
||||
CHECK(fmt::format("|{:^10%Q}|", 123q_m) == "| 123 |");
|
||||
CHECK(fmt::format("|{:*<10%Q}|", 123q_m) == "|123*******|");
|
||||
CHECK(fmt::format("|{:*>10%Q}|", 123q_m) == "|*******123|");
|
||||
CHECK(fmt::format("|{:*^10%Q}|", 123q_m) == "|***123****|");
|
||||
}
|
||||
|
||||
SECTION("symbol only format {:%q} on a quantity")
|
||||
{
|
||||
CHECK(fmt::format("|{:0%q}|", 123m) == "|m|");
|
||||
CHECK(fmt::format("|{:10%q}|", 123m) == "|m |");
|
||||
CHECK(fmt::format("|{:<10%q}|", 123m) == "|m |");
|
||||
CHECK(fmt::format("|{:>10%q}|", 123m) == "| m|");
|
||||
CHECK(fmt::format("|{:^10%q}|", 123m) == "| m |");
|
||||
CHECK(fmt::format("|{:*<10%q}|", 123m) == "|m*********|");
|
||||
CHECK(fmt::format("|{:*>10%q}|", 123m) == "|*********m|");
|
||||
CHECK(fmt::format("|{:*^10%q}|", 123m) == "|****m*****|");
|
||||
CHECK(fmt::format("|{:0%q}|", 123q_m) == "|m|");
|
||||
CHECK(fmt::format("|{:10%q}|", 123q_m) == "|m |");
|
||||
CHECK(fmt::format("|{:<10%q}|", 123q_m) == "|m |");
|
||||
CHECK(fmt::format("|{:>10%q}|", 123q_m) == "| m|");
|
||||
CHECK(fmt::format("|{:^10%q}|", 123q_m) == "| m |");
|
||||
CHECK(fmt::format("|{:*<10%q}|", 123q_m) == "|m*********|");
|
||||
CHECK(fmt::format("|{:*>10%q}|", 123q_m) == "|*********m|");
|
||||
CHECK(fmt::format("|{:*^10%q}|", 123q_m) == "|****m*****|");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -796,24 +796,24 @@ TEST_CASE("sign specification", "[text][fmt]")
|
||||
|
||||
SECTION("default format {} on a quantity")
|
||||
{
|
||||
CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", 1m) == "1 m,+1 m,1 m, 1 m");
|
||||
CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", -1m) == "-1 m,-1 m,-1 m,-1 m");
|
||||
CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", 1q_m) == "1 m,+1 m,1 m, 1 m");
|
||||
CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", -1q_m) == "-1 m,-1 m,-1 m,-1 m");
|
||||
CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", inf) == "inf m,+inf m,inf m, inf m");
|
||||
CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", nan) == "nan m,+nan m,nan m, nan m");
|
||||
}
|
||||
|
||||
SECTION("full format {:%Q %q} on a quantity")
|
||||
{
|
||||
CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", 1m) == "1m,+1m,1m, 1m");
|
||||
CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", -1m) == "-1m,-1m,-1m,-1m");
|
||||
CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", 1q_m) == "1q_m,+1q_m,1q_m, 1q_m");
|
||||
CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", -1q_m) == "-1q_m,-1q_m,-1q_m,-1q_m");
|
||||
CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", inf) == "infm,+infm,infm, infm");
|
||||
CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", nan) == "nanm,+nanm,nanm, nanm");
|
||||
}
|
||||
|
||||
SECTION("value only format {:%Q} on a quantity")
|
||||
{
|
||||
CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", 1m) == "1,+1,1, 1");
|
||||
CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", -1m) == "-1,-1,-1,-1");
|
||||
CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", 1q_m) == "1,+1,1, 1");
|
||||
CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", -1q_m) == "-1,-1,-1,-1");
|
||||
CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", inf) == "inf,+inf,inf, inf");
|
||||
CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", nan) == "nan,+nan,nan, nan");
|
||||
}
|
||||
@@ -821,8 +821,8 @@ TEST_CASE("sign specification", "[text][fmt]")
|
||||
|
||||
TEST_CASE("sign specification for unit only", "[text][fmt][exception]")
|
||||
{
|
||||
CHECK_THROWS_MATCHES(fmt::format("{:+%q}", 1m), fmt::format_error, Message("sign not allowed for a quantity unit"));
|
||||
CHECK_THROWS_MATCHES(fmt::format("{:-%q}", 1m), fmt::format_error, Message("sign not allowed for a quantity unit"));
|
||||
CHECK_THROWS_MATCHES(fmt::format("{:+%q}", 1q_m), fmt::format_error, Message("sign not allowed for a quantity unit"));
|
||||
CHECK_THROWS_MATCHES(fmt::format("{:-%q}", 1q_m), fmt::format_error, Message("sign not allowed for a quantity unit"));
|
||||
}
|
||||
|
||||
|
||||
@@ -830,35 +830,35 @@ TEST_CASE("precision specification", "[text][fmt]")
|
||||
{
|
||||
SECTION("default format {} on a quantity")
|
||||
{
|
||||
CHECK(fmt::format("{:.1}", 1.2345m) == "1.2 m");
|
||||
CHECK(fmt::format("{:.0}", 1.2345m) == "1 m");
|
||||
CHECK(fmt::format("{:.2}", 1.2345m) == "1.23 m");
|
||||
CHECK(fmt::format("{:.3}", 1.2345m) == "1.235 m");
|
||||
CHECK(fmt::format("{:.4}", 1.2345m) == "1.2345 m");
|
||||
CHECK(fmt::format("{:.5}", 1.2345m) == "1.23450 m");
|
||||
CHECK(fmt::format("{:.10}", 1.2345m) == "1.2345000000 m");
|
||||
CHECK(fmt::format("{:.1}", 1.2345q_m) == "1.2 m");
|
||||
CHECK(fmt::format("{:.0}", 1.2345q_m) == "1 m");
|
||||
CHECK(fmt::format("{:.2}", 1.2345q_m) == "1.23 m");
|
||||
CHECK(fmt::format("{:.3}", 1.2345q_m) == "1.235 m");
|
||||
CHECK(fmt::format("{:.4}", 1.2345q_m) == "1.2345 m");
|
||||
CHECK(fmt::format("{:.5}", 1.2345q_m) == "1.23450 m");
|
||||
CHECK(fmt::format("{:.10}", 1.2345q_m) == "1.2345000000 m");
|
||||
}
|
||||
|
||||
SECTION("full format {:%Q %q} on a quantity")
|
||||
{
|
||||
CHECK(fmt::format("{:.0%Q %q}", 1.2345m) == "1 m");
|
||||
CHECK(fmt::format("{:.1%Q %q}", 1.2345m) == "1.2 m");
|
||||
CHECK(fmt::format("{:.2%Q %q}", 1.2345m) == "1.23 m");
|
||||
CHECK(fmt::format("{:.3%Q %q}", 1.2345m) == "1.235 m");
|
||||
CHECK(fmt::format("{:.4%Q %q}", 1.2345m) == "1.2345 m");
|
||||
CHECK(fmt::format("{:.5%Q %q}", 1.2345m) == "1.23450 m");
|
||||
CHECK(fmt::format("{:.10%Q %q}", 1.2345m) == "1.2345000000 m");
|
||||
CHECK(fmt::format("{:.0%Q %q}", 1.2345q_m) == "1 m");
|
||||
CHECK(fmt::format("{:.1%Q %q}", 1.2345q_m) == "1.2 m");
|
||||
CHECK(fmt::format("{:.2%Q %q}", 1.2345q_m) == "1.23 m");
|
||||
CHECK(fmt::format("{:.3%Q %q}", 1.2345q_m) == "1.235 m");
|
||||
CHECK(fmt::format("{:.4%Q %q}", 1.2345q_m) == "1.2345 m");
|
||||
CHECK(fmt::format("{:.5%Q %q}", 1.2345q_m) == "1.23450 m");
|
||||
CHECK(fmt::format("{:.10%Q %q}", 1.2345q_m) == "1.2345000000 m");
|
||||
}
|
||||
|
||||
SECTION("value only format {:%Q} on a quantity")
|
||||
{
|
||||
CHECK(fmt::format("{:.0%Q}", 1.2345m) == "1");
|
||||
CHECK(fmt::format("{:.1%Q}", 1.2345m) == "1.2");
|
||||
CHECK(fmt::format("{:.2%Q}", 1.2345m) == "1.23");
|
||||
CHECK(fmt::format("{:.3%Q}", 1.2345m) == "1.235");
|
||||
CHECK(fmt::format("{:.4%Q}", 1.2345m) == "1.2345");
|
||||
CHECK(fmt::format("{:.5%Q}", 1.2345m) == "1.23450");
|
||||
CHECK(fmt::format("{:.10%Q}", 1.2345m) == "1.2345000000");
|
||||
CHECK(fmt::format("{:.0%Q}", 1.2345q_m) == "1");
|
||||
CHECK(fmt::format("{:.1%Q}", 1.2345q_m) == "1.2");
|
||||
CHECK(fmt::format("{:.2%Q}", 1.2345q_m) == "1.23");
|
||||
CHECK(fmt::format("{:.3%Q}", 1.2345q_m) == "1.235");
|
||||
CHECK(fmt::format("{:.4%Q}", 1.2345q_m) == "1.2345");
|
||||
CHECK(fmt::format("{:.5%Q}", 1.2345q_m) == "1.23450");
|
||||
CHECK(fmt::format("{:.10%Q}", 1.2345q_m) == "1.2345000000");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -866,17 +866,17 @@ TEST_CASE("precision specification for integral representation should throw", "[
|
||||
{
|
||||
SECTION("default format {} on a quantity")
|
||||
{
|
||||
REQUIRE_THROWS_MATCHES(fmt::format("{:.1}", 1m), fmt::format_error, Message("precision not allowed for integral quantity representation"));
|
||||
REQUIRE_THROWS_MATCHES(fmt::format("{:.1}", 1q_m), fmt::format_error, Message("precision not allowed for integral quantity representation"));
|
||||
}
|
||||
|
||||
SECTION("full format {:%Q %q} on a quantity")
|
||||
{
|
||||
REQUIRE_THROWS_MATCHES(fmt::format("{:.1%Q %q}", 1m), fmt::format_error, Message("precision not allowed for integral quantity representation"));
|
||||
REQUIRE_THROWS_MATCHES(fmt::format("{:.1%Q %q}", 1q_m), fmt::format_error, Message("precision not allowed for integral quantity representation"));
|
||||
}
|
||||
|
||||
SECTION("value only format {:%Q} on a quantity")
|
||||
{
|
||||
REQUIRE_THROWS_MATCHES(fmt::format("{:.1%Q}", 1m), fmt::format_error, Message("precision not allowed for integral quantity representation"));
|
||||
REQUIRE_THROWS_MATCHES(fmt::format("{:.1%Q}", 1q_m), fmt::format_error, Message("precision not allowed for integral quantity representation"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,47 +890,47 @@ TEST_CASE("quantity_cast", "[text][ostream]")
|
||||
|
||||
SECTION("int to double representation")
|
||||
{
|
||||
const auto q = 121km / 2h;
|
||||
const auto q = 121q_km / 2q_h;
|
||||
|
||||
SECTION("original")
|
||||
{
|
||||
stream << q;
|
||||
CHECK(stream.str() == "60 km/h");
|
||||
CHECK(stream.str() == "60.q_km/h");
|
||||
}
|
||||
|
||||
SECTION("int")
|
||||
{
|
||||
stream << quantity_cast<int>(q);
|
||||
CHECK(stream.str() == "60 km/h");
|
||||
CHECK(stream.str() == "60.q_km/h");
|
||||
}
|
||||
|
||||
SECTION("double")
|
||||
{
|
||||
stream << quantity_cast<double>(q);
|
||||
CHECK(stream.str() == "60 km/h");
|
||||
CHECK(stream.str() == "60.q_km/h");
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("double to int representation")
|
||||
{
|
||||
const auto q = 121.km / 2h;
|
||||
const auto q = 121.q_km / 2q_h;
|
||||
|
||||
SECTION("original")
|
||||
{
|
||||
stream << q;
|
||||
CHECK(stream.str() == "60.5 km/h");
|
||||
CHECK(stream.str() == "60.5.q_km/h");
|
||||
}
|
||||
|
||||
SECTION("int")
|
||||
{
|
||||
stream << quantity_cast<int>(q);
|
||||
CHECK(stream.str() == "60 km/h");
|
||||
CHECK(stream.str() == "60.q_km/h");
|
||||
}
|
||||
|
||||
SECTION("double")
|
||||
{
|
||||
stream << quantity_cast<double>(q);
|
||||
CHECK(stream.str() == "60.5 km/h");
|
||||
CHECK(stream.str() == "60.5.q_km/h");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -51,123 +51,123 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
|
||||
{
|
||||
SECTION("time")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1ns) == "1 ns");
|
||||
CHECK(fmt::format("{}", 1us) == "1 µs");
|
||||
CHECK(fmt::format("{}", 1ms) == "1 ms");
|
||||
CHECK(fmt::format("{}", 1q_ns) == "1 ns");
|
||||
CHECK(fmt::format("{}", 1q_us) == "1 µs");
|
||||
CHECK(fmt::format("{}", 1q_ms) == "1 ms");
|
||||
}
|
||||
|
||||
SECTION("length")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1mm) == "1 mm");
|
||||
CHECK(fmt::format("{}", 1cm) == "1 cm");
|
||||
CHECK(fmt::format("{}", 1km) == "1 km");
|
||||
CHECK(fmt::format("{}", 1ft) == "1 ft");
|
||||
CHECK(fmt::format("{}", 1ft_us) == "1 ft(us)");
|
||||
CHECK(fmt::format("{}", 1yd) == "1 yd");
|
||||
CHECK(fmt::format("{}", 1in) == "1 in");
|
||||
CHECK(fmt::format("{}", 1fathom) == "1 fathom");
|
||||
CHECK(fmt::format("{}", 1fathom_us) == "1 fathom(us)");
|
||||
CHECK(fmt::format("{}", 1mi) == "1 mi");
|
||||
CHECK(fmt::format("{}", 1mi_us) == "1 mi(us)");
|
||||
CHECK(fmt::format("{}", 1naut_mi) == "1 mi(naut)");
|
||||
CHECK(fmt::format("{}", 1ch) == "1 ch");
|
||||
CHECK(fmt::format("{}", 1rd) == "1 rd");
|
||||
CHECK(fmt::format("{}", 1thou) == "1 thou");
|
||||
CHECK(fmt::format("{}", 1pc) == "1 pc");
|
||||
CHECK(fmt::format("{}", 1ly) == "1 ly");
|
||||
CHECK(fmt::format("{}", 1pc) == "1 pc");
|
||||
CHECK(fmt::format("{}", 1angstrom) == "1 angstrom");
|
||||
CHECK(fmt::format("{}", 1au) == "1 au");
|
||||
CHECK(fmt::format("{}", 1pica_comp) == "1 pica(comp)");
|
||||
CHECK(fmt::format("{}", 1pica_prn) == "1 pica(prn)");
|
||||
CHECK(fmt::format("{}", 1point_comp) == "1 point(comp)");
|
||||
CHECK(fmt::format("{}", 1point_prn) == "1 point(prn)");
|
||||
CHECK(fmt::format("{}", 1q_mm) == "1 mm");
|
||||
CHECK(fmt::format("{}", 1q_cm) == "1 cm");
|
||||
CHECK(fmt::format("{}", 1q_km) == "1.q_km");
|
||||
CHECK(fmt::format("{}", 1q_ft) == "1 ft");
|
||||
CHECK(fmt::format("{}", 1q_ft_us) == "1 ft(us)");
|
||||
CHECK(fmt::format("{}", 1q_yd) == "1 yd");
|
||||
CHECK(fmt::format("{}", 1q_in) == "1 in");
|
||||
CHECK(fmt::format("{}", 1q_fathom) == "1 fathom");
|
||||
CHECK(fmt::format("{}", 1q_fathom_us) == "1 fathom(us)");
|
||||
CHECK(fmt::format("{}", 1q_mi) == "1 mi");
|
||||
CHECK(fmt::format("{}", 1q_mi_us) == "1 mi(us)");
|
||||
CHECK(fmt::format("{}", 1q_naut_mi) == "1 mi(naut)");
|
||||
CHECK(fmt::format("{}", 1q_ch) == "1 ch");
|
||||
CHECK(fmt::format("{}", 1q_rd) == "1 rd");
|
||||
CHECK(fmt::format("{}", 1q_thou) == "1 thou");
|
||||
CHECK(fmt::format("{}", 1q_pc) == "1 pc");
|
||||
CHECK(fmt::format("{}", 1q_ly) == "1 ly");
|
||||
CHECK(fmt::format("{}", 1q_pc) == "1 pc");
|
||||
CHECK(fmt::format("{}", 1q_angstrom) == "1 angstrom");
|
||||
CHECK(fmt::format("{}", 1q_au) == "1 au");
|
||||
CHECK(fmt::format("{}", 1q_pica_comp) == "1 pica(comp)");
|
||||
CHECK(fmt::format("{}", 1q_pica_prn) == "1 pica(prn)");
|
||||
CHECK(fmt::format("{}", 1q_point_comp) == "1 point(comp)");
|
||||
CHECK(fmt::format("{}", 1q_point_prn) == "1 point(prn)");
|
||||
}
|
||||
|
||||
SECTION("mass")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1kg) == "1 kg");
|
||||
CHECK(fmt::format("{}", 1q_kg) == "1 kg");
|
||||
}
|
||||
|
||||
SECTION("area")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1m2) == "1 m²");
|
||||
CHECK(fmt::format("{}", 1mm2) == "1 mm²");
|
||||
CHECK(fmt::format("{}", 1cm2) == "1 cm²");
|
||||
CHECK(fmt::format("{}", 1km2) == "1 km²");
|
||||
CHECK(fmt::format("{}", 1ft2) == "1 ft²");
|
||||
CHECK(fmt::format("{}", 1q_m2) == "1 m²");
|
||||
CHECK(fmt::format("{}", 1q_mm2) == "1 mm²");
|
||||
CHECK(fmt::format("{}", 1q_cm2) == "1 cm²");
|
||||
CHECK(fmt::format("{}", 1q_km2) == "1.q_km²");
|
||||
CHECK(fmt::format("{}", 1q_ft2) == "1 ft²");
|
||||
}
|
||||
|
||||
SECTION("density")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1kgpm3) == "1 kg/m³");
|
||||
CHECK(fmt::format("{}", 1q_kgpm3) == "1 kg/m³");
|
||||
}
|
||||
|
||||
SECTION("resistance")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1_R) == "1 Ω");
|
||||
CHECK(fmt::format("{}", 1kR) == "1 kΩ");
|
||||
CHECK(fmt::format("{}", 1mR) == "1 mΩ");
|
||||
CHECK(fmt::format("{}", 1MR) == "1 MΩ");
|
||||
CHECK(fmt::format("{}", 1q_R) == "1 Ω");
|
||||
CHECK(fmt::format("{}", 1q_kR) == "1 kΩ");
|
||||
CHECK(fmt::format("{}", 1q_mR) == "1 mΩ");
|
||||
CHECK(fmt::format("{}", 1q_MR) == "1 MΩ");
|
||||
}
|
||||
|
||||
SECTION("voltage")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1V) == "1 V");
|
||||
CHECK(fmt::format("{}", 1mV) == "1 mV");
|
||||
CHECK(fmt::format("{}", 1uV) == "1 µV");
|
||||
CHECK(fmt::format("{}", 1nV) == "1 nV");
|
||||
CHECK(fmt::format("{}", 1pV) == "1 pV");
|
||||
CHECK(fmt::format("{}", 1q_V) == "1 V");
|
||||
CHECK(fmt::format("{}", 1q_mV) == "1 mV");
|
||||
CHECK(fmt::format("{}", 1q_uV) == "1 µV");
|
||||
CHECK(fmt::format("{}", 1q_nV) == "1 nV");
|
||||
CHECK(fmt::format("{}", 1q_pV) == "1 pV");
|
||||
}
|
||||
|
||||
SECTION("volume")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1m3) == "1 m³");
|
||||
CHECK(fmt::format("{}", 1mm3) == "1 mm³");
|
||||
CHECK(fmt::format("{}", 1cm3) == "1 cm³");
|
||||
CHECK(fmt::format("{}", 1km3) == "1 km³");
|
||||
CHECK(fmt::format("{}", 1ft3) == "1 ft³");
|
||||
CHECK(fmt::format("{}", 1q_m3) == "1 m³");
|
||||
CHECK(fmt::format("{}", 1q_mm3) == "1 mm³");
|
||||
CHECK(fmt::format("{}", 1q_cm3) == "1 cm³");
|
||||
CHECK(fmt::format("{}", 1q_km3) == "1.q_km³");
|
||||
CHECK(fmt::format("{}", 1q_ft3) == "1 ft³");
|
||||
}
|
||||
|
||||
SECTION("frequency")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1mHz) == "1 mHz");
|
||||
CHECK(fmt::format("{}", 1kHz) == "1 kHz");
|
||||
CHECK(fmt::format("{}", 1MHz) == "1 MHz");
|
||||
CHECK(fmt::format("{}", 1GHz) == "1 GHz");
|
||||
CHECK(fmt::format("{}", 1THz) == "1 THz");
|
||||
CHECK(fmt::format("{}", 1q_mHz) == "1 mHz");
|
||||
CHECK(fmt::format("{}", 1q_kHz) == "1 kHz");
|
||||
CHECK(fmt::format("{}", 1q_MHz) == "1 MHz");
|
||||
CHECK(fmt::format("{}", 1q_GHz) == "1 GHz");
|
||||
CHECK(fmt::format("{}", 1q_THz) == "1 THz");
|
||||
}
|
||||
|
||||
SECTION("velocity")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1mps) == "1 m/s");
|
||||
CHECK(fmt::format("{}", 1kmph) == "1 km/h");
|
||||
CHECK(fmt::format("{}", 1mph) == "1 mi/h");
|
||||
CHECK(fmt::format("{}", 1q_mps) == "1 m/s");
|
||||
CHECK(fmt::format("{}", 1q_kmph) == "1.q_km/h");
|
||||
CHECK(fmt::format("{}", 1q_mph) == "1 mi/h");
|
||||
}
|
||||
|
||||
SECTION("acceleration")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1mps2) == "1 m/s²");
|
||||
CHECK(fmt::format("{}", 1q_mps2) == "1 m/s²");
|
||||
}
|
||||
|
||||
SECTION("energy")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1mJ) == "1 mJ");
|
||||
CHECK(fmt::format("{}", 1kJ) == "1 kJ");
|
||||
CHECK(fmt::format("{}", 1MJ) == "1 MJ");
|
||||
CHECK(fmt::format("{}", 1GJ) == "1 GJ");
|
||||
CHECK(fmt::format("{}", 1q_mJ) == "1 mJ");
|
||||
CHECK(fmt::format("{}", 1q_kJ) == "1 kJ");
|
||||
CHECK(fmt::format("{}", 1q_MJ) == "1 MJ");
|
||||
CHECK(fmt::format("{}", 1q_GJ) == "1 GJ");
|
||||
}
|
||||
|
||||
SECTION("power")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1mW) == "1 mW");
|
||||
CHECK(fmt::format("{}", 1kW) == "1 kW");
|
||||
CHECK(fmt::format("{}", 1MW) == "1 MW");
|
||||
CHECK(fmt::format("{}", 1GW) == "1 GW");
|
||||
CHECK(fmt::format("{}", 1q_mW) == "1 mW");
|
||||
CHECK(fmt::format("{}", 1q_kW) == "1 kW");
|
||||
CHECK(fmt::format("{}", 1q_MW) == "1 MW");
|
||||
CHECK(fmt::format("{}", 1q_GW) == "1 GW");
|
||||
}
|
||||
|
||||
SECTION("surface tension")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1Npm) == "1 N/m");
|
||||
CHECK(fmt::format("{}", 1q_Npm) == "1 N/m");
|
||||
}
|
||||
}
|
||||
|
@@ -33,23 +33,23 @@ using namespace units::si;
|
||||
TEST_CASE("'pow<N>()' on quantity changes the value and the dimension accordingly", "[math][pow]")
|
||||
{
|
||||
SECTION ("'pow<0>(q)' returns '1'") {
|
||||
CHECK(pow<0>(2m) == 1);
|
||||
CHECK(pow<0>(2q_m) == 1);
|
||||
}
|
||||
|
||||
SECTION ("'pow<1>(q)' returns 'q'") {
|
||||
CHECK(pow<1>(2m) == 2m);
|
||||
CHECK(pow<1>(2q_m) == 2q_m);
|
||||
}
|
||||
|
||||
SECTION ("'pow<2>(q)' squares both the value and a dimension") {
|
||||
CHECK(pow<2>(2m) == 4m2);
|
||||
CHECK(pow<2>(2q_m) == 4q_m2);
|
||||
}
|
||||
|
||||
SECTION ("'pow<3>(q)' cubes both the value and a dimension") {
|
||||
CHECK(pow<3>(2m) == 8m3);
|
||||
CHECK(pow<3>(2q_m) == 8q_m3);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("'sqrt()' on quantity changes the value and the dimension accordingly", "[math][sqrt]")
|
||||
{
|
||||
REQUIRE(sqrt(4m2) == 2m);
|
||||
REQUIRE(sqrt(4q_m2) == 2q_m);
|
||||
}
|
||||
|
@@ -50,17 +50,17 @@ static_assert(centimetre::symbol == "cm");
|
||||
|
||||
// velocity
|
||||
|
||||
static_assert(10cm / 5s == 2cmps);
|
||||
static_assert(10cm / 2cmps == 5s);
|
||||
static_assert(10cm == 2cmps * 5s);
|
||||
static_assert(10q_cm / 5q_s == 2q_cmps);
|
||||
static_assert(10q_cm / 2q_cmps == 5q_s);
|
||||
static_assert(10q_cm == 2q_cmps * 5q_s);
|
||||
|
||||
static_assert(detail::unit_text<dim_velocity, centimetre_per_second>() == "cm/s");
|
||||
|
||||
// area
|
||||
static_assert(std::is_same_v<ratio_divide<centimetre::ratio, dimension_unit<dim_length>::ratio>, ratio<1>>);
|
||||
|
||||
static_assert(1cm * 1cm == 1cm2);
|
||||
static_assert(100cm2 / 10cm == 10cm);
|
||||
static_assert(1q_cm * 1q_cm == 1q_cm2);
|
||||
static_assert(100q_cm2 / 10q_cm == 10q_cm);
|
||||
|
||||
static_assert(detail::unit_text<dim_area, square_centimetre>() == "cm²");
|
||||
|
||||
@@ -68,35 +68,35 @@ static_assert(detail::unit_text<dim_area, square_centimetre>() == "cm²");
|
||||
|
||||
// acceleration
|
||||
|
||||
static_assert(10cmps / 10s == 1Gal);
|
||||
static_assert(10cmps / 1Gal == 10s);
|
||||
static_assert(1Gal * 10s == 10cmps);
|
||||
static_assert(10q_cmps / 10q_s == 1q_Gal);
|
||||
static_assert(10q_cmps / 1q_Gal == 10q_s);
|
||||
static_assert(1q_Gal * 10q_s == 10q_cmps);
|
||||
|
||||
// force
|
||||
|
||||
static_assert(10g * 10Gal == 100dyn);
|
||||
static_assert(100dyn / 10g == 10Gal);
|
||||
static_assert(100dyn / 10Gal == 10g);
|
||||
static_assert(10q_g * 10q_Gal == 100q_dyn);
|
||||
static_assert(100q_dyn / 10q_g == 10q_Gal);
|
||||
static_assert(100q_dyn / 10q_Gal == 10q_g);
|
||||
|
||||
// pressure
|
||||
|
||||
static_assert(10dyn / 10cm2 == 1Ba);
|
||||
static_assert(10dyn / 1Ba == 10cm2);
|
||||
static_assert(1Ba * 10cm2 == 10dyn);
|
||||
static_assert(10q_dyn / 10q_cm2 == 1q_Ba);
|
||||
static_assert(10q_dyn / 1q_Ba == 10q_cm2);
|
||||
static_assert(1q_Ba * 10q_cm2 == 10q_dyn);
|
||||
|
||||
// energy
|
||||
|
||||
static_assert(10dyn * 10cm == 100_erg);
|
||||
static_assert(100_erg / 10cm == 10dyn);
|
||||
static_assert(100_erg / 10dyn == 10cm);
|
||||
static_assert(10q_dyn * 10q_cm == 100q_erg);
|
||||
static_assert(100q_erg / 10q_cm == 10q_dyn);
|
||||
static_assert(100q_erg / 10q_dyn == 10q_cm);
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF OTHER UNITS **************** */
|
||||
|
||||
// power
|
||||
|
||||
static_assert(10_erg / 10s == 1_ergps);
|
||||
static_assert(1_ergps * 10s == 10_erg);
|
||||
static_assert(10_erg / 1_ergps == 10s);
|
||||
static_assert(10q_erg / 10q_s == 1q_ergps);
|
||||
static_assert(1q_ergps * 10q_s == 10q_erg);
|
||||
static_assert(10q_erg / 1q_ergps == 10q_s);
|
||||
|
||||
static_assert(detail::unit_text<dim_power, erg_per_second>() == "erg/s");
|
||||
|
||||
|
@@ -62,7 +62,7 @@ namespace {
|
||||
struct kilogram_per_second : unit<kilogram_per_second> {};
|
||||
struct dim_mass_rate : derived_dimension<dim_mass_rate, kilogram_per_second, units::exp<si::dim_mass, 1>, units::exp<si::dim_time, -1>> {};
|
||||
struct kilogram_per_hour : deduced_unit<kilogram_per_hour, dim_mass_rate, si::kilogram, si::hour> {};
|
||||
constexpr auto a = 1kg / 1h;
|
||||
constexpr auto a = 1q_kg / 1q_h;
|
||||
static_assert(std::is_same_v<decltype(a)::unit, kilogram_per_hour>);
|
||||
|
||||
}
|
||||
|
@@ -31,17 +31,17 @@ using namespace units::data;
|
||||
|
||||
// information
|
||||
|
||||
static_assert(1B == 8b);
|
||||
static_assert(1024b == 1Kib);
|
||||
static_assert(1024B == 1KiB);
|
||||
static_assert(8 * 1024b == 1KiB);
|
||||
static_assert(8 * 1Kib == 1KiB);
|
||||
static_assert(1q_B == 8q_b);
|
||||
static_assert(1024q_b == 1q_Kib);
|
||||
static_assert(1024q_B == 1q_KiB);
|
||||
static_assert(8 * 1024q_b == 1q_KiB);
|
||||
static_assert(8 * 1q_Kib == 1q_KiB);
|
||||
|
||||
static_assert(1Kib == 1024b);
|
||||
static_assert(1Mib == 1024Kib);
|
||||
static_assert(1Gib == 1024Mib);
|
||||
static_assert(1Tib == 1024Gib);
|
||||
static_assert(1Pib == 1024Tib);
|
||||
static_assert(1q_Kib == 1024q_b);
|
||||
static_assert(1q_Mib == 1024q_Kib);
|
||||
static_assert(1q_Gib == 1024q_Mib);
|
||||
static_assert(1q_Tib == 1024q_Gib);
|
||||
static_assert(1q_Pib == 1024q_Tib);
|
||||
|
||||
// bitrate
|
||||
|
||||
|
@@ -30,14 +30,14 @@ namespace {
|
||||
using namespace units::si::literals;
|
||||
using namespace units::international::literals;
|
||||
|
||||
static_assert(std::is_same_v<decltype(pow<0>(2m)), std::int64_t>);
|
||||
static_assert(std::is_same_v<decltype(pow<1>(2m)), decltype(2m)>);
|
||||
static_assert(std::is_same_v<decltype(pow<2>(2m)), decltype(4m2)>);
|
||||
static_assert(std::is_same_v<decltype(pow<2>(2km)), decltype(4km2)>);
|
||||
static_assert(std::is_same_v<decltype(pow<2>(2ft)), decltype(4ft2)>);
|
||||
static_assert(std::is_same_v<decltype(sqrt(4m2)), decltype(2m)>);
|
||||
static_assert(std::is_same_v<decltype(sqrt(4km2)), decltype(2km)>);
|
||||
static_assert(std::is_same_v<decltype(sqrt(4ft2)), decltype(2ft)>);
|
||||
static_assert(std::is_same_v<decltype(pow<0>(2q_m)), std::int64_t>);
|
||||
static_assert(std::is_same_v<decltype(pow<1>(2q_m)), decltype(2q_m)>);
|
||||
static_assert(std::is_same_v<decltype(pow<2>(2q_m)), decltype(4q_m2)>);
|
||||
static_assert(std::is_same_v<decltype(pow<2>(2q_km)), decltype(4q_km2)>);
|
||||
static_assert(std::is_same_v<decltype(pow<2>(2q_ft)), decltype(4q_ft2)>);
|
||||
static_assert(std::is_same_v<decltype(sqrt(4q_m2)), decltype(2q_m)>);
|
||||
static_assert(std::is_same_v<decltype(sqrt(4q_km2)), decltype(2q_km)>);
|
||||
static_assert(std::is_same_v<decltype(sqrt(4q_ft2)), decltype(2q_ft)>);
|
||||
|
||||
|
||||
} // namespace
|
||||
|
@@ -148,19 +148,19 @@ static_assert(length<metre, my_double>(3.14).count() == my_double{3.14});
|
||||
|
||||
static_assert(length<metre, int>(km).count() == 1000);
|
||||
// static_assert(length<metre, int>(length<metre, double>(3.14)).count() == 3); // should not compile (truncating conversion)
|
||||
static_assert(length<metre, int>(quantity_cast<length<metre, my_int>>(3.14m)).count() == 3);
|
||||
static_assert(length<metre, int>(quantity_cast<length<metre, my_int>>(3.14q_m)).count() == 3);
|
||||
// static_assert(length<metre, int>(length<metre, my_double>(1000.0)).count() == 1000); // should not compile (truncating conversion)
|
||||
// static_assert(length<metre, my_int>(1000.0m).count() == my_int{1000}); // should not compile (truncating conversion)
|
||||
static_assert(length<metre, double>(1000.0m).count() == 1000.0);
|
||||
// static_assert(length<metre, my_int>(1000.0q_m).count() == my_int{1000}); // should not compile (truncating conversion)
|
||||
static_assert(length<metre, double>(1000.0q_m).count() == 1000.0);
|
||||
static_assert(length<metre, double>(length<metre, my_double>(1000.0)).count() == 1000.0);
|
||||
static_assert(length<metre, my_double>(1000.0m).count() == my_double{1000.0});
|
||||
static_assert(length<metre, my_double>(1000.0q_m).count() == my_double{1000.0});
|
||||
static_assert(length<metre, double>(km).count() == 1000.0);
|
||||
static_assert(length<metre, my_double>(km).count() == my_double{1000.0});
|
||||
static_assert(length<metre, int>(1km).count() == 1000);
|
||||
// static_assert(length<metre, int>(1s).count() == 1); // should not compile (different dimensions)
|
||||
//static_assert(length<kilometre, int>(1010m).count() == 1); // should not compile (truncating conversion)
|
||||
static_assert(length<kilometre, int>(quantity_cast<length<kilometre, my_int>>(1010m)).count() == 1);
|
||||
static_assert(length<metre, int>(quantity_cast<length<kilometre, my_int>>(1010m)).count() == 1000);
|
||||
static_assert(length<metre, int>(1q_km).count() == 1000);
|
||||
// static_assert(length<metre, int>(1q_s).count() == 1); // should not compile (different dimensions)
|
||||
//static_assert(length<kilometre, int>(1010q_m).count() == 1); // should not compile (truncating conversion)
|
||||
static_assert(length<kilometre, int>(quantity_cast<length<kilometre, my_int>>(1010q_m)).count() == 1);
|
||||
static_assert(length<metre, int>(quantity_cast<length<kilometre, my_int>>(1010q_m)).count() == 1000);
|
||||
|
||||
// assignment operator
|
||||
|
||||
@@ -209,19 +209,19 @@ static_assert([](auto v) {
|
||||
|
||||
// compound assignment
|
||||
|
||||
static_assert((1m += 1m).count() == 2);
|
||||
static_assert((2m -= 1m).count() == 1);
|
||||
static_assert((1m *= 2).count() == 2);
|
||||
static_assert((2m /= 2).count() == 1);
|
||||
static_assert((7m %= 2).count() == 1);
|
||||
static_assert((7m %= 2m).count() == 1);
|
||||
static_assert((1q_m += 1q_m).count() == 2);
|
||||
static_assert((2q_m -= 1q_m).count() == 1);
|
||||
static_assert((1q_m *= 2).count() == 2);
|
||||
static_assert((2q_m /= 2).count() == 1);
|
||||
static_assert((7q_m %= 2).count() == 1);
|
||||
static_assert((7q_m %= 2q_m).count() == 1);
|
||||
// static_assert((7.m %= 2.).count() == 1); // should not compile (operation not allowed for floating-point types)
|
||||
// static_assert((7.m %= 2).count() == 1); // should not compile (operation not allowed for floating-point types)
|
||||
// static_assert((7m %= 2.).count() == 1); // should not compile (operation not allowed for floating-point types)
|
||||
static_assert((7m %= 2m).count() == 1);
|
||||
// static_assert((7q_m %= 2.).count() == 1); // should not compile (operation not allowed for floating-point types)
|
||||
static_assert((7q_m %= 2q_m).count() == 1);
|
||||
// static_assert((7.m %= 2.m).count() == 1); // should not compile (operation not allowed for floating-point types)
|
||||
// static_assert((7.m %= 2m).count() == 1); // should not compile (operation not allowed for floating-point types)
|
||||
// static_assert((7m %= 2.m).count() == 1); // should not compile (operation not allowed for floating-point types)
|
||||
// static_assert((7.m %= 2q_m).count() == 1); // should not compile (operation not allowed for floating-point types)
|
||||
// static_assert((7q_m %= 2.m).count() == 1); // should not compile (operation not allowed for floating-point types)
|
||||
|
||||
// non-member arithmetic operators
|
||||
|
||||
@@ -257,51 +257,51 @@ static_assert(std::is_same_v<decltype(si::time<minute>() / length<metre>()),
|
||||
static_assert(std::is_same_v<decltype(length<metre, int>() % short(1)), length<metre, int>>);
|
||||
static_assert(std::is_same_v<decltype(length<metre, int>() % length<metre, short>(1)), length<metre, int>>);
|
||||
|
||||
static_assert((1m + km).count() == 1001);
|
||||
static_assert((1m + 1km).count() == 1001);
|
||||
static_assert((km - 1m).count() == 999);
|
||||
static_assert((1km - 1m).count() == 999);
|
||||
static_assert((2m * 2).count() == 4);
|
||||
static_assert((3 * 3m).count() == 9);
|
||||
static_assert((4m / 2).count() == 2);
|
||||
static_assert(4m / 2m == 2);
|
||||
static_assert(4km / 2000m == 2);
|
||||
static_assert((7m % 2).count() == 1);
|
||||
static_assert((7m % 2m).count() == 1);
|
||||
static_assert((7km % 2000m).count() == 1000);
|
||||
static_assert((1q_m + km).count() == 1001);
|
||||
static_assert((1q_m + 1q_km).count() == 1001);
|
||||
static_assert((km - 1q_m).count() == 999);
|
||||
static_assert((1q_km - 1q_m).count() == 999);
|
||||
static_assert((2q_m * 2).count() == 4);
|
||||
static_assert((3 * 3q_m).count() == 9);
|
||||
static_assert((4q_m / 2).count() == 2);
|
||||
static_assert(4q_m / 2q_m == 2);
|
||||
static_assert(4q_km / 2000q_m == 2);
|
||||
static_assert((7q_m % 2).count() == 1);
|
||||
static_assert((7q_m % 2q_m).count() == 1);
|
||||
static_assert((7q_km % 2000q_m).count() == 1000);
|
||||
|
||||
static_assert((10km2 * 10km2) / 50km2 == 2km2);
|
||||
static_assert((10q_km2 * 10q_km2) / 50q_km2 == 2q_km2);
|
||||
|
||||
// comparators
|
||||
|
||||
static_assert(2m + 1m == 3m);
|
||||
static_assert(!(2m + 2m == 3m));
|
||||
static_assert(2m + 2m != 3m);
|
||||
static_assert(!(2m + 2m != 4m));
|
||||
static_assert(2m > 1m);
|
||||
static_assert(!(1m > 1m));
|
||||
static_assert(1m < 2m);
|
||||
static_assert(!(2m < 2m));
|
||||
static_assert(2m >= 1m);
|
||||
static_assert(2m >= 2m);
|
||||
static_assert(!(2m >= 3m));
|
||||
static_assert(1m <= 2m);
|
||||
static_assert(2m <= 2m);
|
||||
static_assert(!(3m <= 2m));
|
||||
static_assert(2q_m + 1q_m == 3q_m);
|
||||
static_assert(!(2q_m + 2q_m == 3q_m));
|
||||
static_assert(2q_m + 2q_m != 3q_m);
|
||||
static_assert(!(2q_m + 2q_m != 4q_m));
|
||||
static_assert(2q_m > 1q_m);
|
||||
static_assert(!(1q_m > 1q_m));
|
||||
static_assert(1q_m < 2q_m);
|
||||
static_assert(!(2q_m < 2q_m));
|
||||
static_assert(2q_m >= 1q_m);
|
||||
static_assert(2q_m >= 2q_m);
|
||||
static_assert(!(2q_m >= 3q_m));
|
||||
static_assert(1q_m <= 2q_m);
|
||||
static_assert(2q_m <= 2q_m);
|
||||
static_assert(!(3q_m <= 2q_m));
|
||||
|
||||
static_assert(3m == 3.0m);
|
||||
static_assert(3m != 3.14m);
|
||||
static_assert(2m > 1.0m);
|
||||
static_assert(1.0m < 2m);
|
||||
static_assert(2.0m >= 1m);
|
||||
static_assert(1m <= 2.0m);
|
||||
static_assert(3q_m == 3.0q_m);
|
||||
static_assert(3q_m != 3.14q_m);
|
||||
static_assert(2q_m > 1.0q_m);
|
||||
static_assert(1.0q_m < 2q_m);
|
||||
static_assert(2.0q_m >= 1q_m);
|
||||
static_assert(1q_m <= 2.0q_m);
|
||||
|
||||
static_assert(1000m == 1km);
|
||||
static_assert(1001m != 1km);
|
||||
static_assert(1001m > 1km);
|
||||
static_assert(999m < 1km);
|
||||
static_assert(1000m >= 1km);
|
||||
static_assert(1000m <= 1km);
|
||||
static_assert(1000q_m == 1q_km);
|
||||
static_assert(1001q_m != 1q_km);
|
||||
static_assert(1001q_m > 1q_km);
|
||||
static_assert(999q_m < 1q_km);
|
||||
static_assert(1000q_m >= 1q_km);
|
||||
static_assert(1000q_m <= 1q_km);
|
||||
|
||||
// is_quantity
|
||||
|
||||
@@ -317,35 +317,35 @@ static_assert(std::is_same_v<common_quantity<length<kilometre, long long>, lengt
|
||||
|
||||
// quantity_cast
|
||||
|
||||
static_assert(std::is_same_v<decltype(quantity_cast<scaled_unit<ratio<1>, metre>>(2km))::unit, metre>);
|
||||
static_assert(std::is_same_v<decltype(quantity_cast<scaled_unit<ratio<1>, metre>>(2q_km))::unit, metre>);
|
||||
|
||||
static_assert(quantity_cast<length<metre, int>>(2km).count() == 2000);
|
||||
static_assert(quantity_cast<length<kilometre, int>>(2000m).count() == 2);
|
||||
static_assert(quantity_cast<length<metre, int>>(1.23m).count() == 1);
|
||||
static_assert(quantity_cast<metre>(2km).count() == 2000);
|
||||
static_assert(quantity_cast<kilometre>(2000m).count() == 2);
|
||||
static_assert(quantity_cast<int>(1.23m).count() == 1);
|
||||
static_assert(quantity_cast<length<metre, int>>(2q_km).count() == 2000);
|
||||
static_assert(quantity_cast<length<kilometre, int>>(2000q_m).count() == 2);
|
||||
static_assert(quantity_cast<length<metre, int>>(1.23q_m).count() == 1);
|
||||
static_assert(quantity_cast<metre>(2q_km).count() == 2000);
|
||||
static_assert(quantity_cast<kilometre>(2000q_m).count() == 2);
|
||||
static_assert(quantity_cast<int>(1.23q_m).count() == 1);
|
||||
|
||||
// time
|
||||
|
||||
// static_assert(1s == 1m); // should not compile (different dimensions)
|
||||
static_assert(1h == 3600s);
|
||||
// static_assert(1q_s == 1q_m); // should not compile (different dimensions)
|
||||
static_assert(1q_h == 3600q_s);
|
||||
|
||||
// length
|
||||
|
||||
static_assert(1km == 1000m);
|
||||
static_assert(1km + 1m == 1001m);
|
||||
static_assert(10km / 5km == 2);
|
||||
static_assert(10km / 2 == 5km);
|
||||
static_assert(1q_km == 1000q_m);
|
||||
static_assert(1q_km + 1q_m == 1001q_m);
|
||||
static_assert(10q_km / 5q_km == 2);
|
||||
static_assert(10q_km / 2 == 5q_km);
|
||||
|
||||
// velocity
|
||||
|
||||
static_assert(10m / 5s == 2mps);
|
||||
static_assert(10 / 5s * 1m == 2mps);
|
||||
static_assert(1km / 1s == 1000mps);
|
||||
static_assert(2kmph * 2h == 4km);
|
||||
static_assert(2km / 2kmph == 1h);
|
||||
static_assert(10q_m / 5q_s == 2q_mps);
|
||||
static_assert(10 / 5q_s * 1q_m == 2q_mps);
|
||||
static_assert(1q_km / 1q_s == 1000q_mps);
|
||||
static_assert(2q_kmph * 2q_h == 4q_km);
|
||||
static_assert(2q_km / 2q_kmph == 1q_h);
|
||||
|
||||
static_assert(std::is_same_v<decltype(pow<2>(2m)), decltype(4m2)>);
|
||||
static_assert(std::is_same_v<decltype(pow<2>(2q_m)), decltype(4q_m2)>);
|
||||
|
||||
} // namespace
|
||||
|
@@ -61,15 +61,15 @@ namespace si_test {
|
||||
|
||||
using namespace units::si::literals;
|
||||
|
||||
static_assert(cgs::length<cgs::centimetre>(100) == 1m);
|
||||
static_assert(cgs::mass<cgs::gram>(1'000) == 1kg);
|
||||
static_assert(cgs::time<cgs::second>(1) == 1s);
|
||||
static_assert(cgs::velocity<cgs::centimetre_per_second>(100) == 1mps);
|
||||
static_assert(cgs::acceleration<cgs::gal>(100) == 1mps2);
|
||||
static_assert(cgs::force<cgs::dyne>(100'000) == 1N);
|
||||
static_assert(cgs::energy<cgs::erg>(10'000'000) == 1_J);
|
||||
static_assert(cgs::power<cgs::erg_per_second>(10'000'000) == 1W);
|
||||
static_assert(cgs::pressure<cgs::barye>(10) == 1Pa);
|
||||
static_assert(cgs::length<cgs::centimetre>(100) == 1q_m);
|
||||
static_assert(cgs::mass<cgs::gram>(1'000) == 1q_kg);
|
||||
static_assert(cgs::time<cgs::second>(1) == 1q_s);
|
||||
static_assert(cgs::velocity<cgs::centimetre_per_second>(100) == 1q_mps);
|
||||
static_assert(cgs::acceleration<cgs::gal>(100) == 1q_mps2);
|
||||
static_assert(cgs::force<cgs::dyne>(100'000) == 1q_N);
|
||||
static_assert(cgs::energy<cgs::erg>(10'000'000) == 1q_J);
|
||||
static_assert(cgs::power<cgs::erg_per_second>(10'000'000) == 1q_W);
|
||||
static_assert(cgs::pressure<cgs::barye>(10) == 1q_Pa);
|
||||
|
||||
}
|
||||
|
||||
@@ -77,15 +77,15 @@ namespace cgs_test {
|
||||
|
||||
using namespace units::cgs::literals;
|
||||
|
||||
static_assert(100cm == si::length<si::metre>(1));
|
||||
static_assert(1'000g == si::mass<si::kilogram>(1));
|
||||
static_assert(1s == si::time<si::second>(1));
|
||||
static_assert(100cmps == si::velocity<si::metre_per_second>(1));
|
||||
static_assert(100Gal == si::acceleration<si::metre_per_second_sq>(1));
|
||||
static_assert(100'000dyn == si::force<si::newton>(1));
|
||||
static_assert(10'000'000_erg == si::energy<si::joule>(1));
|
||||
static_assert(10'000'000_ergps == si::power<si::watt>(1));
|
||||
static_assert(10Ba == si::pressure<si::pascal>(1));
|
||||
static_assert(100q_cm == si::length<si::metre>(1));
|
||||
static_assert(1'000q_g == si::mass<si::kilogram>(1));
|
||||
static_assert(1q_s == si::time<si::second>(1));
|
||||
static_assert(100q_cmps == si::velocity<si::metre_per_second>(1));
|
||||
static_assert(100q_Gal == si::acceleration<si::metre_per_second_sq>(1));
|
||||
static_assert(100'000q_dyn == si::force<si::newton>(1));
|
||||
static_assert(10'000'000q_erg == si::energy<si::joule>(1));
|
||||
static_assert(10'000'000q_ergps == si::power<si::watt>(1));
|
||||
static_assert(10q_Ba == si::pressure<si::pascal>(1));
|
||||
|
||||
}
|
||||
|
||||
@@ -94,15 +94,15 @@ namespace both_test {
|
||||
using namespace units::si::literals;
|
||||
using namespace units::cgs::literals;
|
||||
|
||||
// static_assert(100cm == 1m); // ambiguous
|
||||
// static_assert(1'000g == 1kg); // ambiguous
|
||||
static_assert(1s == 1s);
|
||||
static_assert(100cmps == 1mps);
|
||||
static_assert(100Gal == 1mps2);
|
||||
static_assert(100'000dyn == 1N);
|
||||
static_assert(10'000'000_erg == 1_J);
|
||||
static_assert(10'000'000_ergps == 1W);
|
||||
static_assert(10Ba == quantity_cast<double>(1Pa));
|
||||
// static_assert(100q_cm == 1q_m); // ambiguous
|
||||
// static_assert(1'000q_g == 1q_kg); // ambiguous
|
||||
static_assert(1q_s == 1q_s);
|
||||
static_assert(100q_cmps == 1q_mps);
|
||||
static_assert(100q_Gal == 1q_mps2);
|
||||
static_assert(100'000q_dyn == 1q_N);
|
||||
static_assert(10'000'000q_erg == 1q_J);
|
||||
static_assert(10'000'000q_ergps == 1q_W);
|
||||
static_assert(10q_Ba == quantity_cast<double>(1q_Pa));
|
||||
|
||||
}
|
||||
|
||||
@@ -110,41 +110,41 @@ namespace cgs_test {
|
||||
|
||||
// addition
|
||||
|
||||
// static_assert(100cm + si::length<si::metre>(1) == si::length<si::metre>(2)); // should not compile (different dimensions)
|
||||
// static_assert(si::length<si::metre>(1) + 100cm == si::length<si::metre>(2)); // should not compile (different dimensions)
|
||||
static_assert(quantity_cast<si::length<si::metre>>(100cm) + si::length<si::metre>(1) == si::length<si::metre>(2));
|
||||
static_assert(si::length<si::metre>(1) + quantity_cast<si::length<si::metre>>(100cm) == si::length<si::metre>(2));
|
||||
static_assert(100cm + quantity_cast<cgs::length<cgs::centimetre>>(si::length<si::metre>(1)) == 200cm);
|
||||
static_assert(quantity_cast<cgs::length<cgs::centimetre>>(si::length<si::metre>(1)) + 100cm == 200cm);
|
||||
// static_assert(100q_cm + si::length<si::metre>(1) == si::length<si::metre>(2)); // should not compile (different dimensions)
|
||||
// static_assert(si::length<si::metre>(1) + 100q_cm == si::length<si::metre>(2)); // should not compile (different dimensions)
|
||||
static_assert(quantity_cast<si::length<si::metre>>(100q_cm) + si::length<si::metre>(1) == si::length<si::metre>(2));
|
||||
static_assert(si::length<si::metre>(1) + quantity_cast<si::length<si::metre>>(100q_cm) == si::length<si::metre>(2));
|
||||
static_assert(100q_cm + quantity_cast<cgs::length<cgs::centimetre>>(si::length<si::metre>(1)) == 200q_cm);
|
||||
static_assert(quantity_cast<cgs::length<cgs::centimetre>>(si::length<si::metre>(1)) + 100q_cm == 200q_cm);
|
||||
|
||||
// substraction
|
||||
|
||||
// static_assert(500cm - si::length<si::metre>(1) == si::length<si::metre>(4)); // should not compile (different dimensions)
|
||||
// static_assert(si::length<si::metre>(5) - 100cm == si::length<si::metre>(4)); // should not compile (different dimensions)
|
||||
static_assert(quantity_cast<si::length<si::metre>>(500cm) - si::length<si::metre>(1) == si::length<si::metre>(4));
|
||||
static_assert(si::length<si::metre>(5) - quantity_cast<si::length<si::metre>>(100cm) == si::length<si::metre>(4));
|
||||
static_assert(500cm - quantity_cast<cgs::length<cgs::centimetre>>(si::length<si::metre>(1)) == 400cm);
|
||||
static_assert(quantity_cast<cgs::length<cgs::centimetre>>(si::length<si::metre>(5)) - 100cm == 400cm);
|
||||
// static_assert(500q_cm - si::length<si::metre>(1) == si::length<si::metre>(4)); // should not compile (different dimensions)
|
||||
// static_assert(si::length<si::metre>(5) - 100q_cm == si::length<si::metre>(4)); // should not compile (different dimensions)
|
||||
static_assert(quantity_cast<si::length<si::metre>>(500q_cm) - si::length<si::metre>(1) == si::length<si::metre>(4));
|
||||
static_assert(si::length<si::metre>(5) - quantity_cast<si::length<si::metre>>(100q_cm) == si::length<si::metre>(4));
|
||||
static_assert(500q_cm - quantity_cast<cgs::length<cgs::centimetre>>(si::length<si::metre>(1)) == 400q_cm);
|
||||
static_assert(quantity_cast<cgs::length<cgs::centimetre>>(si::length<si::metre>(5)) - 100q_cm == 400q_cm);
|
||||
|
||||
// multiplication
|
||||
|
||||
// static_assert(200cm * si::length<si::metre>(2) == si::area<si::square_metre>(4)); // should not compile (unknown dimension)
|
||||
// static_assert(200q_cm * si::length<si::metre>(2) == si::area<si::square_metre>(4)); // should not compile (unknown dimension)
|
||||
|
||||
static_assert(quantity_cast<si::dim_length>(200cm) * si::length<si::metre>(2) == si::area<si::square_metre>(4));
|
||||
static_assert(200cm * quantity_cast<cgs::dim_length>(si::length<si::metre>(2)) == 40'000cm2);
|
||||
static_assert(quantity_cast<si::dim_length>(200q_cm) * si::length<si::metre>(2) == si::area<si::square_metre>(4));
|
||||
static_assert(200q_cm * quantity_cast<cgs::dim_length>(si::length<si::metre>(2)) == 40'000q_cm2);
|
||||
|
||||
// TODO Add support for quantity_cast on an unknown_dimension?
|
||||
// static_assert(quantity_cast<si::area<si::square_metre>>(200cm * si::length<si::metre>(2)) == si::area<si::square_metre>(4));
|
||||
// static_assert(quantity_cast<si::dim_area>(200cm * si::length<si::metre>(2)) == si::area<si::square_metre>(4));
|
||||
// static_assert(quantity_cast<cgs::area<cgs::square_centimeters>>(200cm * si::length<si::metre>(2)) == 40'000sq_cm);
|
||||
// static_assert(quantity_cast<cgs::dim_area>(200cm * si::length<si::metre>(2)) == 40'000sq_cm);
|
||||
// static_assert(quantity_cast<si::area<si::square_metre>>(200q_cm * si::length<si::metre>(2)) == si::area<si::square_metre>(4));
|
||||
// static_assert(quantity_cast<si::dim_area>(200q_cm * si::length<si::metre>(2)) == si::area<si::square_metre>(4));
|
||||
// static_assert(quantity_cast<cgs::area<cgs::square_centimeters>>(200q_cm * si::length<si::metre>(2)) == 40'000q_sq_cm);
|
||||
// static_assert(quantity_cast<cgs::dim_area>(200q_cm * si::length<si::metre>(2)) == 40'000q_sq_cm);
|
||||
|
||||
// division
|
||||
|
||||
// static_assert(si::area<si::square_metre>(4) / 200cm == si::length<si::metre>(2)); // should not compile (unknown dimension)
|
||||
// static_assert(si::area<si::square_metre>(4) / 200q_cm == si::length<si::metre>(2)); // should not compile (unknown dimension)
|
||||
|
||||
static_assert(si::area<si::square_metre>(4) / quantity_cast<si::length<si::metre>>(200cm) == si::length<si::metre>(2));
|
||||
static_assert(quantity_cast<cgs::area<cgs::square_centimetre>>(si::area<si::square_metre>(4)) / 200cm == 200cm);
|
||||
static_assert(si::area<si::square_metre>(4) / quantity_cast<si::length<si::metre>>(200q_cm) == si::length<si::metre>(2));
|
||||
static_assert(quantity_cast<cgs::area<cgs::square_centimetre>>(si::area<si::square_metre>(4)) / 200q_cm == 200q_cm);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -51,16 +51,16 @@ using namespace units::si;
|
||||
|
||||
// length
|
||||
|
||||
static_assert(1km == 1000m);
|
||||
static_assert(1m == 100cm);
|
||||
static_assert(1m == 10dm);
|
||||
static_assert(1m == 1000mm);
|
||||
static_assert(1hm == 100m);
|
||||
static_assert(1au == 149'597'870'700m);
|
||||
static_assert(1km + 1m == 1001m);
|
||||
static_assert(10km / 5km == 2);
|
||||
static_assert(100mm / 5cm == 2);
|
||||
static_assert(10km / 2 == 5km);
|
||||
static_assert(1q_km == 1000q_m);
|
||||
static_assert(1q_m == 100q_cm);
|
||||
static_assert(1q_m == 10q_dm);
|
||||
static_assert(1q_m == 1000q_mm);
|
||||
static_assert(1q_hm == 100q_m);
|
||||
static_assert(1q_au == 149'597'870'700q_m);
|
||||
static_assert(1q_km + 1q_m == 1001q_m);
|
||||
static_assert(10q_km / 5q_km == 2);
|
||||
static_assert(100q_mm / 5q_cm == 2);
|
||||
static_assert(10q_km / 2 == 5q_km);
|
||||
|
||||
static_assert(millimetre::symbol == "mm");
|
||||
static_assert(centimetre::symbol == "cm");
|
||||
@@ -69,21 +69,21 @@ static_assert(kilometre::symbol == "km");
|
||||
|
||||
// mass
|
||||
|
||||
static_assert(1kg == 1000g);
|
||||
static_assert(1t == 1000kg);
|
||||
static_assert(1q_kg == 1000q_g);
|
||||
static_assert(1q_t == 1000q_kg);
|
||||
|
||||
static_assert(kilogram::symbol == "kg");
|
||||
|
||||
// time
|
||||
|
||||
static_assert(1us == 1000ns);
|
||||
static_assert(1ms == 1000us);
|
||||
static_assert(1s == 1000ms);
|
||||
static_assert(1min == 60s);
|
||||
static_assert(1h == 60min);
|
||||
static_assert(1h == 3600s);
|
||||
static_assert(1_d == 24h);
|
||||
static_assert(1_d == 86'400s);
|
||||
static_assert(1q_us == 1000q_ns);
|
||||
static_assert(1q_ms == 1000q_us);
|
||||
static_assert(1q_s == 1000q_ms);
|
||||
static_assert(1q_min == 60q_s);
|
||||
static_assert(1q_h == 60q_min);
|
||||
static_assert(1q_h == 3600q_s);
|
||||
static_assert(1q_d == 24q_h);
|
||||
static_assert(1q_d == 86'400q_s);
|
||||
|
||||
static_assert(nanosecond::symbol == "ns");
|
||||
static_assert(microsecond::symbol == "µs");
|
||||
@@ -101,11 +101,11 @@ static_assert(millisecond::symbol == "ms");
|
||||
|
||||
// frequency
|
||||
|
||||
static_assert(1000mHz == 1Hz);
|
||||
static_assert(1000Hz == 1kHz);
|
||||
static_assert(1000kHz == 1MHz);
|
||||
static_assert(1000MHz == 1GHz);
|
||||
static_assert(1000GHz == 1THz);
|
||||
static_assert(1000q_mHz == 1q_Hz);
|
||||
static_assert(1000q_Hz == 1q_kHz);
|
||||
static_assert(1000q_kHz == 1q_MHz);
|
||||
static_assert(1000q_MHz == 1q_GHz);
|
||||
static_assert(1000q_GHz == 1q_THz);
|
||||
|
||||
static_assert(millihertz::symbol == "mHz");
|
||||
static_assert(kilohertz::symbol == "kHz");
|
||||
@@ -113,140 +113,140 @@ static_assert(megahertz::symbol == "MHz");
|
||||
static_assert(gigahertz::symbol == "GHz");
|
||||
static_assert(terahertz::symbol == "THz");
|
||||
|
||||
static_assert(2 / 1s == 2Hz);
|
||||
static_assert(120 / 1min == 2Hz);
|
||||
static_assert(1000 / 1s == 1kHz);
|
||||
static_assert(1 / 1ms == 1kHz);
|
||||
static_assert(3.2GHz == 3'200'000'000Hz);
|
||||
static_assert(10Hz * 1min == 600);
|
||||
static_assert(2 / 1Hz == 2s);
|
||||
static_assert(2 / 1q_s == 2q_Hz);
|
||||
static_assert(120 / 1q_min == 2q_Hz);
|
||||
static_assert(1000 / 1q_s == 1q_kHz);
|
||||
static_assert(1 / 1q_ms == 1q_kHz);
|
||||
static_assert(3.2q_GHz == 3'200'000'000q_Hz);
|
||||
static_assert(10q_Hz * 1q_min == 600);
|
||||
static_assert(2 / 1q_Hz == 2q_s);
|
||||
|
||||
// force
|
||||
static_assert(10kg * 10mps2 == 100N);
|
||||
static_assert(100N / 1mps2 == 100kg);
|
||||
static_assert(100N / 1kg == 100mps2);
|
||||
static_assert(10q_kg * 10q_mps2 == 100q_N);
|
||||
static_assert(100q_N / 1q_mps2 == 100q_kg);
|
||||
static_assert(100q_N / 1q_kg == 100q_mps2);
|
||||
|
||||
// pressure
|
||||
|
||||
static_assert(10N / 10m2 == 1Pa);
|
||||
static_assert(10N / 1Pa == 10m2);
|
||||
static_assert(1Pa * 10m2 == 10N);
|
||||
static_assert(10q_N / 10q_m2 == 1q_Pa);
|
||||
static_assert(10q_N / 1q_Pa == 10q_m2);
|
||||
static_assert(1q_Pa * 10q_m2 == 10q_N);
|
||||
|
||||
// energy
|
||||
|
||||
static_assert(1000mJ == 1_J);
|
||||
static_assert(1000_J == 1kJ);
|
||||
static_assert(1000kJ == 1MJ);
|
||||
static_assert(1000MJ == 1GJ);
|
||||
static_assert(1000q_mJ == 1q_J);
|
||||
static_assert(1000q_J == 1q_kJ);
|
||||
static_assert(1000q_kJ == 1q_MJ);
|
||||
static_assert(1000q_MJ == 1q_GJ);
|
||||
|
||||
static_assert(millijoule::symbol == "mJ");
|
||||
static_assert(kilojoule::symbol == "kJ");
|
||||
static_assert(megajoule::symbol == "MJ");
|
||||
static_assert(gigajoule::symbol == "GJ");
|
||||
|
||||
static_assert(10N * 10m == 100_J);
|
||||
static_assert(100_J / 10m == 10N);
|
||||
static_assert(100_J / 10N == 10m);
|
||||
static_assert(10Pa * 10m3 == 100_J);
|
||||
static_assert(100_J / 10Pa == 10m3);
|
||||
static_assert(100_J / 10m3 == 10Pa);
|
||||
static_assert(10q_N * 10q_m == 100q_J);
|
||||
static_assert(100q_J / 10q_m == 10q_N);
|
||||
static_assert(100q_J / 10q_N == 10q_m);
|
||||
static_assert(10q_Pa * 10q_m3 == 100q_J);
|
||||
static_assert(100q_J / 10q_Pa == 10q_m3);
|
||||
static_assert(100q_J / 10q_m3 == 10q_Pa);
|
||||
|
||||
// power
|
||||
|
||||
static_assert(1000mW == 1W);
|
||||
static_assert(1000W == 1kW);
|
||||
static_assert(1000kW == 1MW);
|
||||
static_assert(1000MW == 1GW);
|
||||
static_assert(1000q_mW == 1q_W);
|
||||
static_assert(1000q_W == 1q_kW);
|
||||
static_assert(1000q_kW == 1q_MW);
|
||||
static_assert(1000q_MW == 1q_GW);
|
||||
|
||||
static_assert(milliwatt::symbol == "mW");
|
||||
static_assert(kilowatt::symbol == "kW");
|
||||
static_assert(megawatt::symbol == "MW");
|
||||
static_assert(gigawatt::symbol == "GW");
|
||||
|
||||
static_assert(10_J / 10s == 1W);
|
||||
static_assert(1W * 10s == 10_J);
|
||||
static_assert(10_J / 1W == 10s);
|
||||
static_assert(10q_J / 10q_s == 1q_W);
|
||||
static_assert(1q_W * 10q_s == 10q_J);
|
||||
static_assert(10q_J / 1q_W == 10q_s);
|
||||
|
||||
// electric charge
|
||||
|
||||
static_assert(10A * 10s == 100C);
|
||||
static_assert(100C / 10A == 10s);
|
||||
static_assert(100C / 10s == 10A);
|
||||
static_assert(10q_A * 10q_s == 100q_C);
|
||||
static_assert(100q_C / 10q_A == 10q_s);
|
||||
static_assert(100q_C / 10q_s == 10q_A);
|
||||
|
||||
// voltage
|
||||
|
||||
static_assert(10W / 10A == 1V);
|
||||
static_assert(10W / 1V == 10A);
|
||||
static_assert(1V * 10A == 10W);
|
||||
static_assert(10_J / 10C == 1V);
|
||||
static_assert(10_J / 1V == 10C);
|
||||
static_assert(10C * 1V == 10_J);
|
||||
static_assert(10q_W / 10q_A == 1q_V);
|
||||
static_assert(10q_W / 1q_V == 10q_A);
|
||||
static_assert(1q_V * 10q_A == 10q_W);
|
||||
static_assert(10q_J / 10q_C == 1q_V);
|
||||
static_assert(10q_J / 1q_V == 10q_C);
|
||||
static_assert(10q_C * 1q_V == 10q_J);
|
||||
|
||||
// capacitance
|
||||
|
||||
static_assert(10C / 10V == 1F);
|
||||
static_assert(10C / 1F == 10V);
|
||||
static_assert(10V * 1F == 10C);
|
||||
static_assert(10q_C / 10q_V == 1q_F);
|
||||
static_assert(10q_C / 1q_F == 10q_V);
|
||||
static_assert(10q_V * 1q_F == 10q_C);
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */
|
||||
|
||||
// velocity
|
||||
|
||||
static_assert(std::is_same_v<decltype(1km / 1s), velocity<scaled_unit<ratio<1, 1, 3>, metre_per_second>, std::int64_t>>);
|
||||
static_assert(std::is_same_v<decltype(1q_km / 1q_s), velocity<scaled_unit<ratio<1, 1, 3>, metre_per_second>, std::int64_t>>);
|
||||
|
||||
static_assert(10m / 5s == 2mps);
|
||||
static_assert(10 / 5s * 1m == 2mps);
|
||||
static_assert(1km / 1s == 1000mps);
|
||||
// static_assert(1km / 1h == 1kmph); // should not compile
|
||||
static_assert(1.0km / 1h == 1kmph);
|
||||
static_assert(1000.0m / 3600.0s == 1kmph);
|
||||
static_assert(10q_m / 5q_s == 2q_mps);
|
||||
static_assert(10 / 5q_s * 1q_m == 2q_mps);
|
||||
static_assert(1q_km / 1q_s == 1000q_mps);
|
||||
// static_assert(1q_km / 1q_h == 1q_kmph); // should not compile
|
||||
static_assert(1.0q_km / 1q_h == 1q_kmph);
|
||||
static_assert(1000.0q_m / 3600.0q_s == 1q_kmph);
|
||||
|
||||
static_assert(2kmph * 2h == 4km);
|
||||
// static_assert(2kmph * 15min == 500m); // should not compile
|
||||
static_assert(2kmph * 15.0min == 500m);
|
||||
static_assert(2.0kmph * 15min == 500m);
|
||||
static_assert(2q_kmph * 2q_h == 4q_km);
|
||||
// static_assert(2q_kmph * 15q_min == 500q_m); // should not compile
|
||||
static_assert(2q_kmph * 15.0q_min == 500q_m);
|
||||
static_assert(2.0q_kmph * 15q_min == 500q_m);
|
||||
|
||||
static_assert(2km / 2kmph == 1h);
|
||||
// static_assert(2000m / 2kmph == 1h); // should not compile
|
||||
static_assert(quantity_cast<kilometre>(2000m) / 2kmph == 1h);
|
||||
static_assert(2q_km / 2q_kmph == 1q_h);
|
||||
// static_assert(2000q_m / 2q_kmph == 1q_h); // should not compile
|
||||
static_assert(quantity_cast<kilometre>(2000q_m) / 2q_kmph == 1q_h);
|
||||
|
||||
static_assert(detail::unit_text<dim_velocity, metre_per_second>() == "m/s");
|
||||
static_assert(kilometre_per_hour::symbol == "km/h");
|
||||
|
||||
// acceleration
|
||||
|
||||
static_assert(10mps / 10s == 1mps2);
|
||||
static_assert(10mps / 1mps2 == 10s);
|
||||
static_assert(1mps2 * 10s == 10mps);
|
||||
static_assert(10q_mps / 10q_s == 1q_mps2);
|
||||
static_assert(10q_mps / 1q_mps2 == 10q_s);
|
||||
static_assert(1q_mps2 * 10q_s == 10q_mps);
|
||||
|
||||
static_assert(detail::unit_text<dim_acceleration, metre_per_second_sq>() == "m/s²");
|
||||
|
||||
// area
|
||||
|
||||
static_assert(10m * 10m == 100m2);
|
||||
static_assert(100m2 / 10m == 10m);
|
||||
static_assert(10km * 10km == 100km2);
|
||||
static_assert(1m2 == 10'000cm2);
|
||||
static_assert(1ha == 10'000m2);
|
||||
static_assert(10q_m * 10q_m == 100q_m2);
|
||||
static_assert(100q_m2 / 10q_m == 10q_m);
|
||||
static_assert(10q_km * 10q_km == 100q_km2);
|
||||
static_assert(1q_m2 == 10'000q_cm2);
|
||||
static_assert(1q_ha == 10'000q_m2);
|
||||
|
||||
static_assert(detail::unit_text<dim_area, square_metre>() == "m²");
|
||||
|
||||
// volume
|
||||
|
||||
static_assert(1m * 1m * 1m == 1m3);
|
||||
static_assert(10m2 * 10m == 100m3);
|
||||
static_assert(10km * 10km * 10km == 1000km3);
|
||||
static_assert(1m3 == 1'000'000cm3);
|
||||
static_assert(1dm * 1dm * 1dm == 1_l);
|
||||
static_assert(1000_l == 1m3);
|
||||
static_assert(1q_m * 1q_m * 1q_m == 1q_m3);
|
||||
static_assert(10q_m2 * 10q_m == 100q_m3);
|
||||
static_assert(10q_km * 10q_km * 10q_km == 1000q_km3);
|
||||
static_assert(1q_m3 == 1'000'000q_cm3);
|
||||
static_assert(1q_dm * 1q_dm * 1q_dm == 1q_l);
|
||||
static_assert(1000q_l == 1q_m3);
|
||||
|
||||
static_assert(detail::unit_text<dim_volume, cubic_metre>() == "m³");
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF OTHER UNITS **************** */
|
||||
|
||||
static_assert(10N / 2m == 5Npm);
|
||||
static_assert(10N / 5Npm == 2m);
|
||||
static_assert(2m * 5Npm == 10N);
|
||||
static_assert(10q_N / 2q_m == 5q_Npm);
|
||||
static_assert(10q_N / 5q_Npm == 2q_m);
|
||||
static_assert(2q_m * 5q_Npm == 10q_N);
|
||||
|
||||
static_assert(detail::unit_text<dim_surface_tension, newton_per_metre>() == "N/m");
|
||||
|
||||
|
@@ -42,19 +42,19 @@ using namespace units::international;
|
||||
|
||||
// length
|
||||
|
||||
static_assert(1yd == 0.9144m);
|
||||
static_assert(1yd == 3ft);
|
||||
static_assert(1ft == 12in);
|
||||
static_assert(1mi == 1760yd);
|
||||
static_assert(1q_yd == 0.9144q_m);
|
||||
static_assert(1q_yd == 3q_ft);
|
||||
static_assert(1q_ft == 12q_in);
|
||||
static_assert(1q_mi == 1760q_yd);
|
||||
|
||||
static_assert(5in + 8cm == 207mm);
|
||||
static_assert(5q_in + 8q_cm == 207q_mm);
|
||||
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */
|
||||
|
||||
// velocity
|
||||
|
||||
static_assert(10.0mi / 2h == 5mph);
|
||||
static_assert(10.0q_mi / 2q_h == 5q_mph);
|
||||
|
||||
static_assert(mile_per_hour::symbol == "mi/h");
|
||||
|
||||
|
@@ -31,5 +31,5 @@ constexpr units::Velocity AUTO avg_speed(units::Length AUTO d, units::Time AUTO
|
||||
int main()
|
||||
{
|
||||
using namespace units::si::literals;
|
||||
std::cout << "Average speed = " << avg_speed(240.km, 2h) << '\n';
|
||||
std::cout << "Average speed = " << avg_speed(240.q_km, 2q_h) << '\n';
|
||||
}
|
||||
|
Reference in New Issue
Block a user