mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 12:54:25 +02:00
US system isolated from SI
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
```cpp
|
||||
#include <units/physical/si/velocity.h>
|
||||
#include <units/physical/us/velocity.h>
|
||||
#include <units/format.h>
|
||||
#include <iostream>
|
||||
|
||||
@@ -23,7 +24,7 @@ int main()
|
||||
{
|
||||
using namespace si::literals;
|
||||
Velocity auto v1 = avg_speed(220km, 2h);
|
||||
Velocity auto v2 = avg_speed(si::length<si::mile>(140), si::time<si::hour>(2));
|
||||
Velocity auto v2 = avg_speed(si::length<us::mile>(140), si::time<si::hour>(2));
|
||||
Velocity auto v3 = quantity_cast<si::metre_per_second>(v2);
|
||||
Velocity auto v4 = quantity_cast<int>(v3);
|
||||
|
||||
@@ -152,6 +153,7 @@ fashion:
|
||||
int main()
|
||||
{
|
||||
using namespace si::literals;
|
||||
using namespace us::literals;
|
||||
Velocity auto v1 = avg_speed(220km, 2h);
|
||||
Velocity auto v2 = avg_speed(140mi, 2h);
|
||||
|
||||
|
@@ -150,8 +150,6 @@ struct kilo : units::prefix<kilo, prefix, "k", ratio<1'000>> {};
|
||||
struct metre : named_unit<metre, "m", prefix> {};
|
||||
struct centimetre : prefixed_unit<centimetre, centi, metre> {};
|
||||
struct kilometre : prefixed_unit<kilometre, kilo, metre> {};
|
||||
struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio<9'144, 10'000>, metre> {};
|
||||
struct mile : named_scaled_unit<mile, "mi", no_prefix, ratio<1'760>, yard> {};
|
||||
|
||||
// time
|
||||
struct second : named_unit<second, "s", prefix> {};
|
||||
@@ -160,7 +158,17 @@ struct hour : named_scaled_unit<hour, "h", no_prefix, ratio<3600>, second> {};
|
||||
// velocity
|
||||
struct metre_per_second : unit<metre_per_second> {};
|
||||
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_velocity, kilometre, hour> {};
|
||||
struct mile_per_hour : deduced_unit<mile_per_hour, dim_velocity, mile, hour> {};
|
||||
|
||||
}
|
||||
|
||||
namespace units::us {
|
||||
|
||||
// length
|
||||
struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio<9'144, 10'000>, si::metre> {};
|
||||
struct mile : named_scaled_unit<mile, "mi", no_prefix, ratio<1'760>, yard> {};
|
||||
|
||||
// velocity
|
||||
struct mile_per_hour : deduced_unit<mile_per_hour, si::dim_velocity, mile, si::hour> {};
|
||||
|
||||
}
|
||||
```
|
||||
|
@@ -20,8 +20,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/physical/si/velocity.h>
|
||||
#include <units/physical/cgs/velocity.h>
|
||||
#include <units/physical/si/velocity.h>
|
||||
#include <units/physical/us/velocity.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace {
|
||||
@@ -96,7 +97,7 @@ void example()
|
||||
|
||||
// Customary Units (int)
|
||||
{
|
||||
using namespace units::si::literals;
|
||||
using namespace units::us::literals;
|
||||
constexpr Length AUTO distance = 140mi; // constructed from a UDL
|
||||
constexpr si::time<si::hour, int> duration(2); // constructed from a value
|
||||
|
||||
@@ -112,7 +113,7 @@ void example()
|
||||
|
||||
// Customary Units (double)
|
||||
{
|
||||
using namespace units::si::literals;
|
||||
using namespace units::us::literals;
|
||||
constexpr Length AUTO distance = 140.mi; // constructed from a UDL
|
||||
constexpr si::time<si::hour> duration(2); // constructed from a value
|
||||
|
||||
|
@@ -21,6 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/physical/si/velocity.h>
|
||||
#include <units/physical/us/velocity.h>
|
||||
#include <units/format.h>
|
||||
#include <iostream>
|
||||
|
||||
@@ -35,7 +36,7 @@ int main()
|
||||
{
|
||||
using namespace si::literals;
|
||||
Velocity AUTO v1 = avg_speed(220km, 2h);
|
||||
Velocity AUTO v2 = avg_speed(si::length<si::mile>(140), si::time<si::hour>(2));
|
||||
Velocity AUTO v2 = avg_speed(si::length<us::mile>(140), si::time<si::hour>(2));
|
||||
Velocity AUTO v3 = quantity_cast<si::metre_per_second>(v2);
|
||||
Velocity AUTO v4 = quantity_cast<int>(v3);
|
||||
|
||||
|
@@ -34,7 +34,6 @@ struct dim_area : physical::dim_area<dim_area, square_metre, dim_length> {};
|
||||
struct square_millimetre : deduced_unit<square_millimetre, dim_area, millimetre> {};
|
||||
struct square_centimetre : deduced_unit<square_centimetre, dim_area, centimetre> {};
|
||||
struct square_kilometre : deduced_unit<square_kilometre, dim_area, kilometre> {};
|
||||
struct square_foot : deduced_unit<square_foot, dim_area, foot> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using area = quantity<dim_area, U, Rep>;
|
||||
@@ -57,10 +56,6 @@ constexpr auto operator"" sq_cm(long double l) { return area<square_centimetre,
|
||||
constexpr auto operator"" sq_km(unsigned long long l) { return area<square_kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator"" sq_km(long double l) { return area<square_kilometre, long double>(l); }
|
||||
|
||||
// sq_ft
|
||||
constexpr auto operator"" sq_ft(unsigned long long l) { return area<square_foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" sq_ft(long double l) { return area<square_foot, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
||||
|
@@ -58,30 +58,4 @@ constexpr auto operator"" km(long double l) { return length<kilometre, long doub
|
||||
|
||||
} // namespace literals
|
||||
|
||||
// US customary units
|
||||
struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio<9'144, 10'000>, metre> {};
|
||||
struct foot : named_scaled_unit<foot, "ft", no_prefix, ratio<1, 3>, yard> {};
|
||||
struct inch : named_scaled_unit<inch, "in", no_prefix, ratio<1, 12>, foot> {};
|
||||
struct mile : named_scaled_unit<mile, "mi", no_prefix, ratio<1'760>, yard> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// yd
|
||||
constexpr auto operator"" yd(unsigned long long l) { return length<yard, std::int64_t>(l); }
|
||||
constexpr auto operator"" yd(long double l) { return length<yard, long double>(l); }
|
||||
|
||||
// ft
|
||||
constexpr auto operator"" ft(unsigned long long l) { return length<foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" ft(long double l) { return length<foot, long double>(l); }
|
||||
|
||||
// in
|
||||
constexpr auto operator"" in(unsigned long long l) { return length<inch, std::int64_t>(l); }
|
||||
constexpr auto operator"" in(long double l) { return length<inch, long double>(l); }
|
||||
|
||||
// mi
|
||||
constexpr auto operator"" mi(unsigned long long l) { return length<mile, std::int64_t>(l); }
|
||||
constexpr auto operator"" mi(long double l) { return length<mile, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
||||
|
@@ -33,7 +33,6 @@ struct metre_per_second : unit<metre_per_second> {};
|
||||
struct dim_velocity : physical::dim_velocity<dim_velocity, metre_per_second, dim_length, dim_time> {};
|
||||
|
||||
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_velocity, kilometre, hour> {};
|
||||
struct mile_per_hour : deduced_unit<mile_per_hour, dim_velocity, mile, hour> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using velocity = quantity<dim_velocity, U, Rep>;
|
||||
@@ -48,10 +47,6 @@ constexpr auto operator"" mps(long double l) { return velocity<metre_per_second,
|
||||
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); }
|
||||
|
||||
// mph
|
||||
constexpr auto operator"" mph(unsigned long long l) { return velocity<mile_per_hour, std::int64_t>(l); }
|
||||
constexpr auto operator"" mph(long double l) { return velocity<mile_per_hour, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
||||
|
@@ -34,7 +34,6 @@ struct dim_volume : physical::dim_volume<dim_volume, cubic_metre, dim_length> {}
|
||||
struct cubic_millimetre : deduced_unit<cubic_millimetre, dim_volume, millimetre> {};
|
||||
struct cubic_centimetre : deduced_unit<cubic_centimetre, dim_volume, centimetre> {};
|
||||
struct cubic_kilometre : deduced_unit<cubic_kilometre, dim_volume, kilometre> {};
|
||||
struct cubic_foot : deduced_unit<cubic_foot, dim_volume, foot> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using volume = quantity<dim_volume, U, Rep>;
|
||||
@@ -57,10 +56,6 @@ constexpr auto operator""cub_m(long double l) { return volume<cubic_metre, long
|
||||
constexpr auto operator""cub_km(unsigned long long l) { return volume<cubic_kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator""cub_km(long double l) { return volume<cubic_kilometre, long double>(l); }
|
||||
|
||||
// cub_ft
|
||||
constexpr auto operator""cub_ft(unsigned long long l) { return volume<cubic_foot, std::int64_t>(l); }
|
||||
constexpr auto operator""cub_ft(long double l) { return volume<cubic_foot, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
||||
|
40
src/include/units/physical/us/area.h
Normal file
40
src/include/units/physical/us/area.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/si/area.h>
|
||||
#include <units/physical/us/length.h>
|
||||
|
||||
namespace units::us {
|
||||
|
||||
struct square_foot : deduced_unit<square_foot, si::dim_area, foot> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// sq_ft
|
||||
constexpr auto operator"" sq_ft(unsigned long long l) { return si::area<square_foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" sq_ft(long double l) { return si::area<square_foot, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::us
|
54
src/include/units/physical/us/length.h
Normal file
54
src/include/units/physical/us/length.h
Normal file
@@ -0,0 +1,54 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/si/length.h>
|
||||
|
||||
namespace units::us {
|
||||
|
||||
struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio<9'144, 10'000>, si::metre> {};
|
||||
struct foot : named_scaled_unit<foot, "ft", no_prefix, ratio<1, 3>, yard> {};
|
||||
struct inch : named_scaled_unit<inch, "in", no_prefix, ratio<1, 12>, foot> {};
|
||||
struct mile : named_scaled_unit<mile, "mi", no_prefix, ratio<1'760>, yard> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// 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); }
|
||||
|
||||
// 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); }
|
||||
|
||||
// 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); }
|
||||
|
||||
// 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); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::us
|
40
src/include/units/physical/us/velocity.h
Normal file
40
src/include/units/physical/us/velocity.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/si/velocity.h>
|
||||
#include <units/physical/us/length.h>
|
||||
|
||||
namespace units::us {
|
||||
|
||||
struct mile_per_hour : deduced_unit<mile_per_hour, si::dim_velocity, mile, si::hour> {};
|
||||
|
||||
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); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::us
|
40
src/include/units/physical/us/volume.h
Normal file
40
src/include/units/physical/us/volume.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/si/volume.h>
|
||||
#include <units/physical/us/length.h>
|
||||
|
||||
namespace units::us {
|
||||
|
||||
struct cubic_foot : deduced_unit<cubic_foot, si::dim_volume, foot> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// cub_ft
|
||||
constexpr auto operator""cub_ft(unsigned long long l) { return si::volume<cubic_foot, std::int64_t>(l); }
|
||||
constexpr auto operator""cub_ft(long double l) { return si::volume<cubic_foot, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::us
|
@@ -26,10 +26,14 @@
|
||||
#include "units/physical/si/velocity.h"
|
||||
#include "units/physical/si/volume.h"
|
||||
#include "units/physical/si/surface_tension.h"
|
||||
#include "units/physical/us/area.h"
|
||||
#include "units/physical/us/velocity.h"
|
||||
#include "units/physical/us/volume.h"
|
||||
#include "units/format.h"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
using namespace units::si;
|
||||
using namespace units::us;
|
||||
|
||||
TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
|
||||
{
|
||||
|
@@ -33,6 +33,7 @@ add_library(unit_tests_static
|
||||
si_cgs_test.cpp
|
||||
type_list_test.cpp
|
||||
unit_test.cpp
|
||||
us_test.cpp
|
||||
)
|
||||
target_link_libraries(unit_tests_static
|
||||
PRIVATE
|
||||
|
@@ -59,13 +59,6 @@ static_assert(10km / 5km == 2);
|
||||
static_assert(100mm / 5cm == 2);
|
||||
static_assert(10km / 2 == 5km);
|
||||
|
||||
static_assert(1yd == 0.9144m);
|
||||
static_assert(1yd == 3ft);
|
||||
static_assert(1ft == 12in);
|
||||
static_assert(1mi == 1760yd);
|
||||
|
||||
static_assert(5in + 8cm == 207mm);
|
||||
|
||||
static_assert(millimetre::symbol == "mm");
|
||||
static_assert(centimetre::symbol == "cm");
|
||||
static_assert(kilometre::symbol == "km");
|
||||
@@ -200,8 +193,6 @@ static_assert(1km / 1s == 1000mps);
|
||||
static_assert(1.0km / 1h == 1kmph);
|
||||
static_assert(1000.0m / 3600.0s == 1kmph);
|
||||
|
||||
static_assert(10.0mi / 2h == 5mph);
|
||||
|
||||
static_assert(2kmph * 2h == 4km);
|
||||
// static_assert(2kmph * 15min == 500m); // should not compile
|
||||
static_assert(2kmph * 15.0min == 500m);
|
||||
@@ -213,7 +204,6 @@ static_assert(quantity_cast<kilometre>(2000m) / 2kmph == 1h);
|
||||
|
||||
static_assert(detail::unit_text<dim_velocity, metre_per_second>() == "m/s");
|
||||
static_assert(kilometre_per_hour::symbol == "km/h");
|
||||
static_assert(mile_per_hour::symbol == "mi/h");
|
||||
|
||||
// acceleration
|
||||
|
||||
|
59
test/unit_test/static/us_test.cpp
Normal file
59
test/unit_test/static/us_test.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/physical/si/area.h>
|
||||
#include <units/physical/si/length.h>
|
||||
#include <units/physical/si/velocity.h>
|
||||
#include <units/physical/si/volume.h>
|
||||
#include <units/physical/us/area.h>
|
||||
#include <units/physical/us/length.h>
|
||||
#include <units/physical/us/velocity.h>
|
||||
#include <units/physical/us/volume.h>
|
||||
#include <utility>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace units::si;
|
||||
using namespace units::us;
|
||||
|
||||
/* ************** BASE DIMENSIONS **************** */
|
||||
|
||||
// length
|
||||
|
||||
static_assert(1yd == 0.9144m);
|
||||
static_assert(1yd == 3ft);
|
||||
static_assert(1ft == 12in);
|
||||
static_assert(1mi == 1760yd);
|
||||
|
||||
static_assert(5in + 8cm == 207mm);
|
||||
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */
|
||||
|
||||
// velocity
|
||||
|
||||
static_assert(10.0mi / 2h == 5mph);
|
||||
|
||||
static_assert(mile_per_hour::symbol == "mi/h");
|
||||
|
||||
} // namespace
|
Reference in New Issue
Block a user