Unit Conversion and Dimensional Analysis Library 3.6.1
A compile-time, header-only C++23 dimensional-analysis library
Loading...
Searching...
No Matches
pressure.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------------------------------
2//
3// UnitConversion: A compile-time c++23 unit conversion library with no dependencies
4//
5//--------------------------------------------------------------------------------------------------
6//
7// The MIT License (MIT)
8//
9// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10// and associated documentation files (the "Software"), to deal in the Software without
11// restriction, including without limitation the rights to use, copy, modify, merge, publish,
12// distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
13// Software is furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in all copies or
16// substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
19// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23//
24//--------------------------------------------------------------------------------------------------
25//
26// Copyright (c) 2016 Nic Holthaus
27//
28//--------------------------------------------------------------------------------------------------
29//
30// ATTRIBUTION:
31// Parts of this work have been adapted from:
32// http://stackoverflow.com/questions/35069778/create-comparison-trait-for-template-classes-whose-parameters-are-in-a-different
33// http://stackoverflow.com/questions/28253399/check-traits-for-all-variadic-template-arguments/28253503
34// http://stackoverflow.com/questions/36321295/rational-approximation-of-square-root-of-stdratio-at-compile-time?noredirect=1#comment60266601_36321295
35// https://github.com/swatanabe/cppnow17-units
36//
37//--------------------------------------------------------------------------------------------------
38//
41//
42//--------------------------------------------------------------------------------------------------
43
44#pragma once
45
46#ifndef units_pressure_h_
47#define units_pressure_h_
48
49#ifdef _MSC_VER
50#pragma push_macro("pascal")
51#undef pascal
52#endif // _MSC_VER
53
54#if defined(__MINGW64__) || defined(__MINGW32__)
55# pragma push_macro("pascal")
56# undef pascal
57#endif // __MINGW64__ or __MINGW32__
58
59#include <units/force.h>
60#include <units/length.h>
61
62namespace units
63{
73 UNIT_ADD(pressure, bars, bar, conversion_factor<std::ratio<100>, kilo<pascals_>>)
74 UNIT_ADD(pressure, millibars, mbar, conversion_factor<std::ratio<1>, milli<bars_>>)
75 UNIT_ADD(pressure, atmospheres, atm, conversion_factor<std::ratio<101325>, pascals_>)
76 UNIT_ADD(pressure, pounds_per_square_inch, psi, compound_conversion_factor<force::pounds_, inverse<squared<inches_>>>)
77 UNIT_ADD(pressure, torrs, torr, conversion_factor<std::ratio<1, 760>, atmospheres_>)
78 UNIT_ADD(pressure, millimeters_of_mercury, mmHg, conversion_factor<std::ratio<26664477483LL, 200000000LL>, pascals_>)
79 UNIT_ADD(pressure, inches_of_mercury, inHg, conversion_factor<std::ratio<254, 10>, millimeters_of_mercury_>)
80
81 UNIT_ADD(pressure, technical_atmospheres, at, conversion_factor<std::ratio<1961330, 20>, pascals_>)
82 UNIT_ADD(pressure, pounds_per_square_foot, psf, compound_conversion_factor<force::pounds_, inverse<squared<feet_>>>)
83 UNIT_ADD(pressure, kips_per_square_inch, ksi, conversion_factor<std::ratio<1000>, pounds_per_square_inch_>)
84 UNIT_ADD(pressure, baryes, Ba, conversion_factor<std::ratio<1, 10>, pascals_>)
85 UNIT_ADD(pressure, piezes, pz, conversion_factor<std::ratio<1000>, pascals_>)
86 UNIT_ADD(pressure, centimeters_of_water, cmH2O, conversion_factor<std::ratio<1961330, 20000>, pascals_>)
87 UNIT_ADD(pressure, millimeters_of_water, mmH2O, conversion_factor<std::ratio<1, 10>, centimeters_of_water_>)
88 UNIT_ADD(pressure, inches_of_water, inH2O, conversion_factor<std::ratio<254, 100>, centimeters_of_water_>)
89
91} // namespace units
92
93#ifdef _MSC_VER
94#pragma pop_macro("pascal")
95#endif // _MSC_VER
96
97#if defined(__MINGW64__) || defined(__MINGW32__)
98# pragma pop_macro("pascal")
99#endif // __MINGW64__ or __MINGW32_
100
101#endif // units_pressure_h_
#define UNIT_ADD(namespaceName, namePlural, abbreviation,...)
Macro for generating the boilerplate code needed for a new unit.
Definition core.h:447
#define UNIT_ADD_WITH_METRIC_PREFIXES(namespaceName, namePlural, abbreviation,...)
Macro for generating the boilerplate code needed for a new unit, including its metric prefixes from f...
Definition core.h:529
#define UNIT_ADD_DIMENSION_TRAIT(unitdimension, ConceptName)
Macro to create the is_dimension_unit type trait and the ConceptName concept.
Definition core.h:488
units representing force values
typename detail::compound_impl< Cf, Cfs... >::type compound_conversion_factor
Represents a conversion factor made up from other conversion factors.
Definition core.h:1953
typename detail::prefix< std::kilo, Cf >::type kilo
< Represents the type of class Cf with the metric 'hecto' prefix appended.
Definition core.h:2003
typename detail::prefix< std::milli, Cf >::type milli
< Represents the type of class Cf with the metric 'micro' prefix appended.
Definition core.h:1998
typename detail::squared_impl< Cf >::type squared
represents the unit type of class U squared
Definition core.h:1668
typename detail::inverse_impl< Cf >::type inverse
represents the inverse unit type of class U.
Definition core.h:1641
units representing length values
STL namespace.
dimension_divide< force, area > pressure
< Represents an SI derived unit of volumetric flow rate
Definition core.h:1346
namespace for unit types and containers representing force values
namespace for unit types and containers representing pressure values
Unit Conversion Library namespace.
Definition units.h:106
Type representing an arbitrary conversion factor between units.
Definition core.h:1563