]>
git.proxmox.com Git - ceph.git/blob - 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
4 // Copyright (C) 2003-2008 Matthias Christian Schabel
5 // Copyright (C) 2008 Steven Watanabe
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)
14 \brief temperature.cpp
17 Conversions between Fahrenheit and Kelvin for absolute temperatures and
18 temperature differences.
23 //[ temperature_output_1
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>
46 #include <boost/units/base_units/temperature/fahrenheit.hpp>
48 using namespace boost::units
;
54 namespace fahrenheit
{
56 //[temperature_snippet_1
57 typedef temperature::fahrenheit_base_unit::unit_type temperature
;
58 typedef get_system
<temperature
>::type system
;
60 BOOST_UNITS_STATIC_CONSTANT(degree
,temperature
);
61 BOOST_UNITS_STATIC_CONSTANT(degrees
,temperature
);
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
);
78 quantity
<absolute
<si::temperature
> > T2p(T1p
);
79 quantity
<si::temperature
> T2v(T1v
);
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
;
89 std::cout
<< T1p
<< std::endl
90 << absolute_conv_type::convert(T1p
) << std::endl
93 << relative_conv_type::convert(T1v
) << std::endl