]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/units/example/temperature.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / units / example / temperature.cpp
1 // Boost.Units - A C++ library for zero-overhead dimensional analysis and
2 // unit/quantity manipulation and conversion
3 //
4 // Copyright (C) 2003-2008 Matthias Christian Schabel
5 // Copyright (C) 2008 Steven Watanabe
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See
8 // accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 /**
12 \file
13
14 \brief temperature.cpp
15
16 \details
17 Conversions between Fahrenheit and Kelvin for absolute temperatures and
18 temperature differences.
19
20 Output:
21 @verbatim
22
23 //[ temperature_output_1
24 { 32 } F
25 { 273.15 } K
26 { 273.15 } K
27 [ 32 ] F
28 [ 17.7778 ] K
29 [ 17.7778 ] K
30 //]
31
32 @endverbatim
33 **/
34
35 #include <iomanip>
36 #include <iostream>
37
38 #include <boost/units/absolute.hpp>
39 #include <boost/units/get_system.hpp>
40 #include <boost/units/io.hpp>
41 #include <boost/units/unit.hpp>
42 #include <boost/units/quantity.hpp>
43 #include <boost/units/systems/si/temperature.hpp>
44 #include <boost/units/detail/utility.hpp>
45
46 #include <boost/units/base_units/temperature/fahrenheit.hpp>
47
48 using namespace boost::units;
49
50 namespace boost {
51
52 namespace units {
53
54 namespace fahrenheit {
55
56 //[temperature_snippet_1
57 typedef temperature::fahrenheit_base_unit::unit_type temperature;
58 typedef get_system<temperature>::type system;
59
60 BOOST_UNITS_STATIC_CONSTANT(degree,temperature);
61 BOOST_UNITS_STATIC_CONSTANT(degrees,temperature);
62 //]
63
64 } // fahrenheit
65
66 } // namespace units
67
68 } // namespace boost
69
70 int main()
71 {
72 //[temperature_snippet_3
73 quantity<absolute<fahrenheit::temperature> > T1p(
74 32.0*absolute<fahrenheit::temperature>());
75 quantity<fahrenheit::temperature> T1v(
76 32.0*fahrenheit::degrees);
77
78 quantity<absolute<si::temperature> > T2p(T1p);
79 quantity<si::temperature> T2v(T1v);
80 //]
81
82 typedef conversion_helper<
83 quantity<absolute<fahrenheit::temperature> >,
84 quantity<absolute<si::temperature> > > absolute_conv_type;
85 typedef conversion_helper<
86 quantity<fahrenheit::temperature>,
87 quantity<si::temperature> > relative_conv_type;
88
89 std::cout << T1p << std::endl
90 << absolute_conv_type::convert(T1p) << std::endl
91 << T2p << std::endl
92 << T1v << std::endl
93 << relative_conv_type::convert(T1v) << std::endl
94 << T2v << std::endl
95 << std::endl;
96
97 return 0;
98 }