Split the various non-si length units into their own namespaces.

new namespaces are
international ( combination of us and imperial + Canada etc)
iau  (https://www.iau.org/
imperial ( old imperial units)
typographical ( for sizes of printing fonts etc)

These namespace are based on some research , mainly on wikipedia.
Look in src/include/units/physical/si/length.h to see links to see the references to documentation justifying the change.

Unfortunately there are 3 foot units for example, an old imperial version, an old us version and an international version, which is more recent and attempts to unify the two previous ones. All versions have slight changes in value, so I opted to use the international version
The main change in the layout is that inch,foot and yard have been moved from us to international.

With this modification, I also modified the physical/us/area.hpp, volume.hpp and volume.hpp headers to refer to the international units.
This may not be correct, but if the modified us::foot (rather than international foot is used as a basis for these units, then
there is a ratio integer overflow during compilation, probably due to taking 3rd power of a ratio. After this commit. I will try to show that on another branch.
This commit is contained in:
Andy Little
2020-01-10 02:03:27 +00:00
committed by Mateusz Pusz
parent 868842bd46
commit 283e9d81a3
13 changed files with 325 additions and 142 deletions

View File

@ -97,7 +97,7 @@ void example()
// Customary Units (int)
{
using namespace units::us::literals;
using namespace units::international::literals;
constexpr Length AUTO distance = 140mi; // constructed from a UDL
constexpr si::time<si::hour, int> duration(2); // constructed from a value
@ -113,7 +113,7 @@ void example()
// Customary Units (double)
{
using namespace units::us::literals;
using namespace units::international::literals;
constexpr Length AUTO distance = 140.mi; // constructed from a UDL
constexpr si::time<si::hour> duration(2); // constructed from a value

View File

@ -17,7 +17,11 @@
*/
#include <units/physical/si/length.h>
#include <units/physical/international/length.h>
#include <units/physical/us/length.h>
#include <units/physical/iau/length.h>
#include <units/physical/typographic/length.h>
#include <units/physical/imperial/length.h>
#include <units/physical/si/area.h>
#include <units/physical/si/volume.h>
#include <units/physical/si/time.h>
@ -41,55 +45,55 @@ namespace {
using AU = units::si::length<units::si::astronomical_unit,Rep>;
template <typename Rep = double>
using in = units::si::length<units::us::inch,Rep>;
using in = units::si::length<units::international::inch,Rep>;
template <typename Rep = double>
using angstrom = units::si::length<units::si::angstrom,Rep>;
using angstrom = units::si::length<units::iau::angstrom,Rep>;
template <typename Rep = double>
using ch = units::si::length<units::si::chain,Rep>;
using ch = units::si::length<units::imperial::chain,Rep>;
template <typename Rep = double>
using fathom = units::si::length<units::si::fathom,Rep>;
using fathom = units::si::length<units::international::fathom,Rep>;
#if 1
template <typename Rep = double>
using fathom_us = units::si::length<units::us::fathom,Rep>;
#endif
template <typename Rep = double>
using ft = units::si::length<units::international::foot,Rep>;
#if 1
template <typename Rep = double>
using ft_us = units::si::length<units::us::foot,Rep>;
#endif
template <typename Rep = double>
using ly = units::si::length<units::iau::light_year,Rep>;
template <typename Rep = double>
using fathom_us = units::si::length<units::si::fathom_us,Rep>;
using mi = units::si::length<units::international::mile,Rep>;
template <typename Rep = double>
using ft = units::si::length<units::us::foot,Rep>;
using mi_naut = units::si::length<units::international::nautical_mile,Rep>;
template <typename Rep = double>
using ft_us = units::si::length<units::si::foot_us,Rep>;
using pc = units::si::length<units::iau::parsec,Rep>;
template <typename Rep = double>
using ly = units::si::length<units::si::light_year,Rep>;
using pica_comp = units::si::length<units::typographic::pica_comp,Rep>;
template <typename Rep = double>
using mi = units::si::length<units::si::mile,Rep>;
using pica_prn = units::si::length<units::typographic::pica_prn,Rep>;
template <typename Rep = double>
using mi_naut = units::si::length<units::si::nautical_mile,Rep>;
using point_comp = units::si::length<units::typographic::point_comp,Rep>;
template <typename Rep = double>
using pc = units::si::length<units::si::parsec,Rep>;
using point_prn = units::si::length<units::typographic::point_prn,Rep>;
template <typename Rep = double>
using pica_comp = units::si::length<units::si::pica_comp,Rep>;
using rd = units::si::length<units::imperial::rod,Rep>;
template <typename Rep = double>
using pica_prn = units::si::length<units::si::pica_prn,Rep>;
template <typename Rep = double>
using point_comp = units::si::length<units::si::point_comp,Rep>;
template <typename Rep = double>
using point_prn = units::si::length<units::si::point_prn,Rep>;
template <typename Rep = double>
using rd = units::si::length<units::si::rod,Rep>;
template <typename Rep = double>
using yd = units::si::length<units::us::yard,Rep>;
using yd = units::si::length<units::international::yard,Rep>;
}
@ -118,13 +122,15 @@ namespace {
#include <iostream>
using namespace units::si::literals;
//using namespace units::si;
using namespace units::international;
void simple_quantities()
{
using distance = length::m<>;
using time = time::s<>;
distance constexpr km = 1.0km;
distance constexpr miles = 1q_mi;
distance constexpr miles = 1.0mi;
time constexpr sec = 1s;
time constexpr min = 1min;
@ -143,7 +149,7 @@ void quantities_with_typed_units()
{
length::km<> constexpr km = 1km;
length::mi<> constexpr miles = 1q_mi;
length::mi<> constexpr miles = 1.0mi;
std::cout.precision(6);
@ -168,9 +174,13 @@ void quantities_with_typed_units()
std::cout << " = " << length::angstrom<>(meter) << '\n';
std::cout << " = " << length::ch<>(meter) << '\n';
std::cout << " = " << length::fathom<>(meter) << '\n';
#if 1
std::cout << " = " << length::fathom_us<>(meter) << '\n';
#endif
std::cout << " = " << length::ft<>(meter) << '\n';
std::cout << " = " << length::ft_us<>(meter) << '\n';
#if 1
std::cout << " = " << length::ft_us<>(meter) << '\n';
#endif
std::cout << " = " << length::in<>(meter) << '\n';
std::cout << " = " << length::ly<>(meter) << '\n';
std::cout << " = " << length::mi<>(meter) << '\n';

View File

@ -36,7 +36,7 @@ int main()
{
using namespace si::literals;
Velocity AUTO v1 = avg_speed(220km, 2h);
Velocity AUTO v2 = avg_speed(si::length<us::mile>(140), si::time<si::hour>(2));
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);

View File

@ -0,0 +1,47 @@
// The MIT License (MIT)
//
// Copyright (c) 2018 Mateusz Pusz
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#include <units/physical/si/length.h>
namespace units::iau {
struct light_year : named_scaled_unit<light_year,"ly(iau)",no_prefix,ratio<946073,100000,15>,si::metre> {};
struct parsec : named_scaled_unit<parsec,"pc(iau)",no_prefix,ratio<1542839,500000,16>,si::metre> {};
struct angstrom : named_scaled_unit<angstrom,"angstrom(iau)",no_prefix,ratio<1,1,-10>,si::metre> {};
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"" 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"" 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); }
} // namespace literals
} // namespace units::iau

View File

@ -0,0 +1,43 @@
// 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::imperial {
struct chain : named_scaled_unit<chain,"ch",no_prefix,ratio<502921,250000,1>, si::metre> {};
struct rod : named_scaled_unit<rod,"rd",no_prefix, ratio<502921,100000>,si::metre> {};
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"" 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); }
} // namespace literals
} // namespace units::si

View File

@ -0,0 +1,103 @@
// 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>
/*
international units of length are defined in terms of the si metre
*/
namespace units::international {
//international yard
//https://en.wikipedia.org/wiki/International_yard_and_pound
struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio<9'144, 1'000,-1>, si::metre> {};
//international foot
//https://en.wikipedia.org/wiki/Foot_(unit)#International_foot
struct foot : named_scaled_unit<foot, "ft", no_prefix, ratio<3'048,1'000,-1>, si::metre> {};
//https://en.wikipedia.org/wiki/Fathom#International_fathom
struct fathom : named_scaled_unit<fathom, "fathom",no_prefix,ratio<1'828,1'000>,si::metre > {};
//international inch
//https://en.wikipedia.org/wiki/Inch#Equivalences
struct inch : named_scaled_unit<inch, "in", no_prefix, ratio<254,100,-2>, si::metre> {};
//intrnational mile
//https://en.wikipedia.org/wiki/Mile#International_mile
struct mile : named_scaled_unit<mile, "mi", no_prefix, ratio<25'146,15'625,3>, si::metre> {};
//international nautical mile
//https://en.wikipedia.org/wiki/Mile#Nautical_mile
struct nautical_mile : named_scaled_unit<nautical_mile,"mi(naut)",no_prefix, ratio<463,250,3>,si::metre> {};
#if 0
//https://en.wikipedia.org/wiki/Thousandth_of_an_inch
struct thou : named_scaled_unit<thou,"thou",no_prefix,ratio<127,50,-5>,si::metre> {};
#endif
// different name for thou
//https://en.wikipedia.org/wiki/Thousandth_of_an_inch
struct mil : named_scaled_unit<mil,"mil",no_prefix,ratio<127,50,-5>,si::metre> {};
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); }
// 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); }
// 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); }
// 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); }
#if 0
// 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); }
#endif
// 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); }
} // namespace literals
} //namespace units::international

View File

@ -37,31 +37,6 @@ struct kilometre : prefixed_unit<kilometre, kilo, metre> {};
struct femtometre : prefixed_unit<femtometre,femto,metre> {};
struct astronomical_unit : named_scaled_unit<astronomical_unit, "au", no_prefix, ratio<149'597'870'700>, metre> {};
#if 0
struct inch : named_scaled_unit<inch,"in(imp)",no_prefix,ratio<127,50,-2>, metre> {};
struct foot : named_scaled_unit<foot,"ft(imp)",no_prefix,ratio<381,125,-1>, metre> {};
struct yard : named_scaled_unit<yard,"yd(imp)",no_prefix,ratio<1143,125,-1>, metre> {};
#endif
struct foot_us : named_scaled_unit<foot_us,"ft(us)",no_prefix,ratio<1524003,500000,-1>, metre> {};
struct fathom : named_scaled_unit<fathom,"fathom(imp)",no_prefix,ratio<1143,625>, metre> {};
struct fathom_us : named_scaled_unit<fathom_us,"fathom(us)",no_prefix,ratio<457201,250000>,metre> {};
struct chain : named_scaled_unit<chain,"ch(us)",no_prefix,ratio<502921,250000,1>, metre> {};
#if 0
struct thou : named_scaled_unit<thou,"thou",no_prefix,ratio<127,50,-5>,metre> {};
#endif
struct mil : named_scaled_unit<mil,"mil",no_prefix,ratio<127,50,-5>,metre> {};
struct light_year : named_scaled_unit<light_year,"ly(iau)",no_prefix,ratio<946073,100000,15>,metre> {};
struct mile : named_scaled_unit<mile,"mi(imp)",no_prefix,ratio<25146,15625,3>,metre> {};
struct nautical_mile : named_scaled_unit<nautical_mile,"mi(naut)",no_prefix, ratio<463,250,3>,metre> {};
struct parsec : named_scaled_unit<parsec,"pc(iau)",no_prefix,ratio<1542839,500000,16>,metre> {};
struct pica_comp : named_scaled_unit<pica_comp,"pica(comp)",no_prefix,ratio<4233333,1000000,-3>,metre> {};
struct pica_prn : named_scaled_unit<pica_prn,"pica(prn)",no_prefix,ratio<2108759,500000,-3>,metre> {};
struct point_comp : named_scaled_unit<point_comp,"point(comp)",no_prefix,ratio<1763889,500000,-4>,metre> {};
struct point_prn : named_scaled_unit<point_prn,"point(prn)", no_prefix, ratio<1757299,500000,-4>,metre> {};
struct rod : named_scaled_unit<rod,"rd(us)",no_prefix, ratio<502921,100000>,metre> {};
struct angstrom : named_scaled_unit<angstrom,"angstrom(nru)",no_prefix,ratio<1,1,-10>,metre> {};
struct dim_length : physical::dim_length<metre> {};
@ -74,14 +49,14 @@ inline namespace literals {
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); }
// 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); }
// 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); }
// 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); }
// 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); }
@ -101,64 +76,6 @@ constexpr auto operator"" km(long double l) { return length<kilometre, long doub
// 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); }
#if 0
constexpr auto operator"" q_in(unsigned long long l) { return length<inch, std::int64_t>(l); }
constexpr auto operator"" q_in(long double l) { return length<inch, long double>(l); }
constexpr auto operator"" q_ft(unsigned long long l) { return length<foot, std::int64_t>(l); }
constexpr auto operator"" q_ft(long double l) { return length<foot, long double>(l); }
constexpr auto operator"" q_yd(unsigned long long l) { return length<yard, std::int64_t>(l); }
constexpr auto operator"" q_yd(long double l) { return length<yard, long double>(l); }
#endif
constexpr auto operator"" ft_us(unsigned long long l) { return length<foot_us, std::int64_t>(l); }
constexpr auto operator"" ft_us(long double l) { return length<foot_us, long double>(l); }
constexpr auto operator"" fathom(unsigned long long l) { return length<fathom, std::int64_t>(l); }
constexpr auto operator"" fathom(long double l) { return length<fathom, long double>(l); }
constexpr auto operator"" fathom_us(unsigned long long l) { return length<fathom_us, std::int64_t>(l); }
constexpr auto operator"" fathom_us(long double l) { return length<fathom_us, long double>(l); }
constexpr auto operator"" ch(unsigned long long l) { return length<chain, std::int64_t>(l); }
constexpr auto operator"" ch(long double l) { return length<chain, long double>(l); }
#if 0
constexpr auto operator"" thou(unsigned long long l) { return length<thou, std::int64_t>(l); }
constexpr auto operator"" thou(long double l) { return length<thou, long double>(l); }
#endif
constexpr auto operator"" mil(unsigned long long l) { return length<mil, std::int64_t>(l); }
constexpr auto operator"" mil(long double l) { return length<mil, long double>(l); }
constexpr auto operator"" ly(unsigned long long l) { return length<light_year, std::int64_t>(l); }
constexpr auto operator"" ly(long double l) { return length<light_year, long double>(l); }
constexpr auto operator"" q_mi(unsigned long long l) { return length<mile, std::int64_t>(l); }
constexpr auto operator"" q_mi(long double l) { return length<mile, long double>(l); }
constexpr auto operator"" pc(unsigned long long l) { return length<parsec, std::int64_t>(l); }
constexpr auto operator"" pc(long double l) { return length<parsec, long double>(l); }
constexpr auto operator"" mi_naut(unsigned long long l) { return length<nautical_mile, std::int64_t>(l); }
constexpr auto operator"" mi_naut(long double l) { return length<nautical_mile, long double>(l); }
constexpr auto operator"" pica_comp(unsigned long long l) { return length<pica_comp, std::int64_t>(l); }
constexpr auto operator"" pica_comp(long double l) { return length<pica_comp, long double>(l); }
constexpr auto operator"" pica_prn(unsigned long long l) { return length<pica_prn, std::int64_t>(l); }
constexpr auto operator"" pica_prn(long double l) { return length<pica_prn, long double>(l); }
constexpr auto operator"" point_comp(unsigned long long l) { return length<point_comp, std::int64_t>(l); }
constexpr auto operator"" point_comp(long double l) { return length<point_comp, long double>(l); }
constexpr auto operator"" point_prn(unsigned long long l) { return length<point_prn, std::int64_t>(l); }
constexpr auto operator"" point_prn(long double l) { return length<point_prn, long double>(l); }
constexpr auto operator"" rd(unsigned long long l) { return length<rod, std::int64_t>(l); }
constexpr auto operator"" rd(long double l) { return length<rod, long double>(l); }
constexpr auto operator"" angstrom(unsigned long long l) { return length<angstrom, std::int64_t>(l); }
constexpr auto operator"" angstrom(long double l) { return length<angstrom, long double>(l); }
} // namespace literals

View File

@ -0,0 +1,55 @@
// 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::typographic {
struct pica_comp : named_scaled_unit<pica_comp,"pica(comp)",no_prefix,ratio<4233333,1000000,-3>,si::metre> {};
struct pica_prn : named_scaled_unit<pica_prn,"pica(prn)",no_prefix,ratio<2108759,500000,-3>,si::metre> {};
struct point_comp : named_scaled_unit<point_comp,"point(comp)",no_prefix,ratio<1763889,500000,-4>,si::metre> {};
struct point_prn : named_scaled_unit<point_prn,"point(prn)", no_prefix, ratio<1757299,500000,-4>,si::metre> {};
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); }
// 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); }
// 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); }
// 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); }
} // namespace literals
} // namespace units::typographic

View File

@ -23,11 +23,11 @@
#pragma once
#include <units/physical/si/area.h>
#include <units/physical/us/length.h>
#include <units/physical/international/length.h>
namespace units::us {
struct square_foot : deduced_unit<square_foot, si::dim_area, foot> {};
struct square_foot : deduced_unit<square_foot, si::dim_area, international::foot> {};
inline namespace literals {

View File

@ -26,29 +26,35 @@
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> {};
#if 1
//https://en.wikipedia.org/wiki/Foot_(unit)#US_survey_foot
//https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
//struct foot : named_scaled_unit<foot,"ft(us)",no_prefix,ratio<3'048,1'000,-1>, si::metre> {};
//################### causes integer overflow when converting for volume #######################
struct foot : named_scaled_unit<foot,"ft(us)",no_prefix,ratio<1'524'003,5,-6>, si::metre> {};
//#############################################################################################
//https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
struct fathom : named_scaled_unit<fathom,"fathom(us)",no_prefix,ratio<6,1>,us::foot> {};
//https://en.wikipedia.org/wiki/Mile#U.S._survey_mile
//https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
struct mile : named_scaled_unit<mile,"mile(us)",no_prefix,ratio<5280,1000,3>,us::foot> {};
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_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); }
// 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); }
// 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); }
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); }
} // namespace literals
#endif
} // namespace units::us

View File

@ -23,11 +23,11 @@
#pragma once
#include <units/physical/si/velocity.h>
#include <units/physical/us/length.h>
#include <units/physical/international/length.h>
namespace units::us {
struct mile_per_hour : deduced_unit<mile_per_hour, si::dim_velocity, mile, si::hour> {};
struct mile_per_hour : deduced_unit<mile_per_hour, si::dim_velocity, international::mile, si::hour> {};
inline namespace literals {

View File

@ -23,11 +23,11 @@
#pragma once
#include <units/physical/si/volume.h>
#include <units/physical/us/length.h>
#include <units/physical/international/length.h>
namespace units::us {
struct cubic_foot : deduced_unit<cubic_foot, si::dim_volume, foot> {};
struct cubic_foot : deduced_unit<cubic_foot, si::dim_volume, international::foot> {};
inline namespace literals {

View File

@ -22,6 +22,7 @@
#include <units/physical/si/area.h>
#include <units/physical/si/length.h>
#include <units/physical/international/length.h>
#include <units/physical/si/velocity.h>
#include <units/physical/si/volume.h>
#include <units/physical/us/area.h>
@ -35,6 +36,7 @@ namespace {
using namespace units;
using namespace units::si;
using namespace units::us;
using namespace units::international;
/* ************** BASE DIMENSIONS **************** */