units Namespace Reference

MIT License. More...

Classes

struct  unit
 
struct  is_unit
 
struct  is_unit< unit< Rep, Ratio, UnitType > >
 

Typedefs

template<typename Rep , typename Ratio = std::ratio<1>>
using distance = unit< Rep, Ratio, unit_type::distance >
 
using nanometres = distance< double, std::nano >
 
using micrometres = distance< double, std::micro >
 
using millimetres = distance< double, std::milli >
 
using centimetres = distance< double, std::centi >
 
using decimetres = distance< double, std::deci >
 
using metres = distance< double >
 
using kilometres = distance< double, std::kilo >
 
using nanometers = nanometres
 
using micrometers = micrometres
 
using millimeters = millimetres
 
using centimeters = centimetres
 
using decimeters = decimetres
 
using meters = metres
 
using kilometers = kilometres
 
using feet = distance< double, std::ratio_multiply< std::ratio< 381, 1250 >, metres::ratio >>
 
using thous = distance< double, std::ratio_divide< feet::ratio, std::ratio< 12000 >>>
 
using inches = distance< double, std::ratio_divide< feet::ratio, std::ratio< 12 >>>
 
using links = distance< double, std::ratio_multiply< std::ratio< 33, 50 >, feet::ratio >>
 
using yards = distance< double, std::ratio_multiply< std::ratio< 3 >, feet::ratio >>
 
using rods = distance< double, std::ratio_multiply< std::ratio< 25 >, links::ratio >>
 
using chains = distance< double, std::ratio_multiply< std::ratio< 4 >, rods::ratio >>
 
using furlongs = distance< double, std::ratio_multiply< std::ratio< 10 >, chains::ratio >>
 
using miles = distance< double, std::ratio_multiply< std::ratio< 5280 >, feet::ratio >>
 
using leagues = distance< double, std::ratio_multiply< std::ratio< 15840 >, feet::ratio >>
 
using fathoms = distance< double, std::ratio_multiply< std::ratio< 608, 100 >, feet::ratio >>
 
using cables = distance< double, std::ratio_multiply< std::ratio< 608 >, feet::ratio >>
 
using nautical_miles = distance< double, std::ratio_multiply< std::ratio< 6080 >, feet::ratio >>
 
using earth_radii = distance< long double, std::ratio_multiply< std::ratio< 6371 >, kilometres::ratio >>
 
using lunar_distances = distance< long double, std::ratio_multiply< std::ratio< 384402 >, kilometres::ratio >>
 
using astronimical_units = distance< long double, std::ratio< 149597870700 >>
 
using light_years = distance< long double, std::ratio_multiply< std::ratio< 94607304725808, 10 >, kilometres::ratio >>
 
using parsecs = distance< long double, std::ratio_multiply< std::ratio< 308567758146719, 10 >, kilometres::ratio >>
 
template<typename Rep , typename Ratio = std::ratio<1>>
using mass = unit< Rep, Ratio, unit_type::mass >
 
using picograms = mass< double, std::pico >
 
using nanograms = mass< double, std::nano >
 
using micrograms = mass< double, std::micro >
 
using milligrams = mass< double, std::milli >
 
using grams = mass< double >
 
using kilograms = mass< double, std::kilo >
 
using tons = mass< double, std::ratio_multiply< std::ratio< 1000 >, kilograms::ratio >>
 
using pounds = mass< double, std::ratio_multiply< std::ratio< 45359237, 100000000 >, kilograms::ratio >>
 
using grains = mass< double, std::ratio_divide< pounds::ratio, std::ratio< 7000 >>>
 
using drams = mass< double, std::ratio_multiply< std::ratio< 2734375, 100000 >, grains::ratio >>
 
using ounces = mass< double, std::ratio_multiply< std::ratio< 16 >, drams::ratio >>
 
using us_hundredweight = mass< double, std::ratio_multiply< std::ratio< 100 >, pounds::ratio >>
 
using long_hundredweight = mass< double, std::ratio_multiply< std::ratio< 112 >, pounds::ratio >>
 
using short_ton = mass< double, std::ratio_multiply< std::ratio< 2000 >, pounds::ratio >>
 
using long_ton = mass< double, std::ratio_multiply< std::ratio< 2240 >, pounds::ratio >>
 

Functions

template<typename ToUnit , typename Rep , typename Ratio , typename UnitType >
constexpr auto unit_cast (unit< Rep, Ratio, UnitType > from) -> typename std::enable_if< is_unit< ToUnit >::value, ToUnit >::type
 
template<typename Rep1 , typename Ratio1 , typename UnitType1 , typename Rep2 , typename Ratio2 , typename UnitType2 >
constexpr auto operator+ (unit< Rep1, Ratio1, UnitType1 > lhs, unit< Rep2, Ratio2, UnitType2 > rhs) -> typename std::common_type< unit< Rep1, Ratio1, UnitType1 >, unit< Rep2, Ratio2, UnitType2 >>::type
 
template<typename Rep1 , typename Ratio1 , typename UnitType1 , typename Rep2 , typename Ratio2 , typename UnitType2 >
constexpr auto operator- (unit< Rep1, Ratio1, UnitType1 > lhs, unit< Rep2, Ratio2, UnitType2 > rhs) -> typename std::common_type< unit< Rep1, Ratio1, UnitType1 >, unit< Rep2, Ratio2, UnitType2 >>::type
 
template<typename Rep1 , typename Ratio , typename UnitType , typename Rep2 >
constexpr auto operator* (unit< Rep1, Ratio, UnitType > lhs, Rep2 const scalar) -> unit< typename std::common_type< Rep1, Rep2 >::type, Ratio, UnitType >
 
template<typename Rep1 , typename Rep2 , typename Ratio , typename UnitType >
constexpr auto operator* (Rep1 const scalar, unit< Rep2, Ratio, UnitType > rhs) -> unit< typename std::common_type< Rep1, Rep2 >::type, Ratio, UnitType >
 
template<typename Rep1 , typename Ratio , typename UnitType , typename Rep2 >
constexpr auto operator/ (unit< Rep1, Ratio, UnitType > lhs, Rep2 const scalar) -> unit< typename std::common_type< Rep1, Rep2 >::type, Ratio, UnitType >
 
template<typename Rep1 , typename Ratio1 , typename UnitType1 , typename Rep2 , typename Ratio2 , typename UnitType2 >
constexpr auto operator% (unit< Rep1, Ratio1, UnitType1 > lhs, unit< Rep2, Ratio2, UnitType2 > rhs) -> typename std::common_type< unit< Rep1, Ratio1, UnitType1 >, unit< Rep2, Ratio2, UnitType2 >>::type
 
template<typename Rep1 , typename Ratio , typename UnitType , typename Rep2 >
constexpr auto operator% (unit< Rep1, Ratio, UnitType > lhs, Rep2 const scalar) -> typename detail::unit_div_mod< Rep1, Ratio, UnitType, Rep2 >::type
 
template<typename Rep1 , typename Ratio1 , typename UnitType1 , typename Rep2 , typename Ratio2 , typename UnitType2 >
constexpr bool operator== (unit< Rep1, Ratio1, UnitType1 > lhs, unit< Rep2, Ratio2, UnitType2 > rhs)
 
template<typename Rep1 , typename Ratio1 , typename UnitType1 , typename Rep2 , typename Ratio2 , typename UnitType2 >
constexpr bool operator!= (unit< Rep1, Ratio1, UnitType1 > lhs, unit< Rep2, Ratio2, UnitType2 > rhs)
 
template<typename Rep1 , typename Ratio1 , typename UnitType1 , typename Rep2 , typename Ratio2 , typename UnitType2 >
constexpr bool operator< (unit< Rep1, Ratio1, UnitType1 > lhs, unit< Rep2, Ratio2, UnitType2 > rhs)
 
template<typename Rep1 , typename Ratio1 , typename UnitType1 , typename Rep2 , typename Ratio2 , typename UnitType2 >
constexpr bool operator<= (unit< Rep1, Ratio1, UnitType1 > lhs, unit< Rep2, Ratio2, UnitType2 > rhs)
 
template<typename Rep1 , typename Ratio1 , typename UnitType1 , typename Rep2 , typename Ratio2 , typename UnitType2 >
constexpr bool operator> (unit< Rep1, Ratio1, UnitType1 > lhs, unit< Rep2, Ratio2, UnitType2 > rhs)
 
template<typename Rep1 , typename Ratio1 , typename UnitType1 , typename Rep2 , typename Ratio2 , typename UnitType2 >
constexpr bool operator>= (unit< Rep1, Ratio1, UnitType1 > lhs, unit< Rep2, Ratio2, UnitType2 > rhs)
 
template<typename CharT , typename Traits , typename Rep , typename Ratio , typename UnitType >
std::basic_ostream< CharT,
Traits > & 
operator<< (std::basic_ostream< CharT, Traits > &os, unit< Rep, Ratio, UnitType > const &u)
 

Detailed Description

MIT License.

Copyright (c) 2016-2017 David Brown

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.