<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Class template quantity</title> <link rel="stylesheet" href="../../boostbook.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> <link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> <link rel="up" href="../../boost_units/Reference.html#header.boost.units.quantity_hpp" title="Header <boost/units/quantity.hpp>"> <link rel="prev" href="root.html" title="Function template root"> <link rel="next" href="quantity_BOOST_UNITS_DI_id1404125.html" title="Class template quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y>"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table cellpadding="2" width="100%"><tr> <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> <td align="center"><a href="../../../../index.html">Home</a></td> <td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> <td align="center"><a href="../../../../more/index.htm">More</a></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="root.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_units/Reference.html#header.boost.units.quantity_hpp"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="quantity_BOOST_UNITS_DI_id1404125.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a> </div> <div class="refentry" title="Class template quantity"> <a name="boost.units.quantity"></a><div class="titlepage"></div> <div class="refnamediv"> <h2><span class="refentrytitle">Class template quantity</span></h2> <p>boost::units::quantity — class declaration </p> </div> <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="emphasis"><em>// In header: <<a class="link" href="../../boost_units/Reference.html#header.boost.units.quantity_hpp" title="Header <boost/units/quantity.hpp>">boost/units/quantity.hpp</a>> </em></span><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit, <span class="bold"><strong>typename</strong></span> Y = double> <span class="bold"><strong>class</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a> { <span class="bold"><strong>public</strong></span>: <span class="emphasis"><em>// types</em></span> <span class="bold"><strong>typedef</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit, Y > <a name="boost.units.quantity.this_type"></a>this_type; <span class="bold"><strong>typedef</strong></span> Y <a name="boost.units.quantity.value_type"></a>value_type; <span class="bold"><strong>typedef</strong></span> Unit <a name="boost.units.quantity.unit_type"></a>unit_type; <span class="emphasis"><em>// <a class="link" href="quantity.html#boost.units.quantityconstruct-copy-destruct">construct/copy/destruct</a></em></span> <a class="link" href="quantity.html#id1403875-bb">quantity</a>(); <a class="link" href="quantity.html#id1403876-bb">quantity</a>(unspecified_null_pointer_constant_type); <a class="link" href="quantity.html#id1403884-bb">quantity</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &); <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> YY> <a class="link" href="quantity.html#id1403904-bb">quantity</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit, YY > &, <span class="emphasis"><em>unspecified</em></span> = 0); <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> YY> <a class="link" href="quantity.html#id1403934-bb">quantity</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit, YY > &, <span class="emphasis"><em>unspecified</em></span> = 0); <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <a class="link" href="quantity.html#id1403986-bb">quantity</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > &, <span class="emphasis"><em>unspecified</em></span> = 0); <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <a class="link" href="quantity.html#id1404021-bb">quantity</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > &, <span class="emphasis"><em>unspecified</em></span> = 0); <a class="link" href="quantity.html#id1404112-bb">quantity</a>(<span class="bold"><strong>const</strong></span> value_type &, <span class="bold"><strong>int</strong></span>); quantity& <a class="link" href="quantity.html#id1403894-bb"><span class="bold"><strong>operator</strong></span>=</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &); <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> YY> quantity& <a class="link" href="quantity.html#id1403965-bb"><span class="bold"><strong>operator</strong></span>=</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit, YY > &); <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> quantity& <a class="link" href="quantity.html#id1404056-bb"><span class="bold"><strong>operator</strong></span>=</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > &); <span class="emphasis"><em>// <a class="link" href="quantity.html#id1403670-bb">private member functions</a></em></span> <span class="type"></span> <a class="link" href="quantity.html#id1403674-bb">BOOST_MPL_ASSERT_NOT</a>(<span class="emphasis"><em>unspecified</em></span>) ; <span class="emphasis"><em>// <a class="link" href="quantity.html#id1403687-bb">public member functions</a></em></span> <span class="type"><span class="bold"><strong>const</strong></span> value_type &</span> <a class="link" href="quantity.html#id1403690-bb">value</a>() <span class="bold"><strong>const</strong></span>; <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a class="link" href="quantity.html#id1403706-bb"><span class="bold"><strong>operator</strong></span>+=</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > &) ; <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a class="link" href="quantity.html#id1403742-bb"><span class="bold"><strong>operator</strong></span>-=</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > &) ; <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a class="link" href="quantity.html#id1403773-bb"><span class="bold"><strong>operator</strong></span>*=</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > &) ; <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a class="link" href="quantity.html#id1403804-bb"><span class="bold"><strong>operator</strong></span>/=</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > &) ; <span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a class="link" href="quantity.html#id1403839-bb"><span class="bold"><strong>operator</strong></span>*=</a>(<span class="bold"><strong>const</strong></span> value_type &) ; <span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a class="link" href="quantity.html#id1403859-bb"><span class="bold"><strong>operator</strong></span>/=</a>(<span class="bold"><strong>const</strong></span> value_type &) ; <span class="emphasis"><em>// <a class="link" href="quantity.html#id1404082-bb">public static functions</a></em></span> <span class="type"><span class="bold"><strong>static</strong></span> <a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a></span> <a class="link" href="quantity.html#id1404086-bb">from_value</a>(<span class="bold"><strong>const</strong></span> value_type &) ; };</pre></div> <div class="refsect1" title="Description"> <a name="id1950836"></a><h2>Description</h2> <div class="refsect2" title="quantity public construct/copy/destruct"> <a name="id1950839"></a><h3> <a name="boost.units.quantityconstruct-copy-destruct"></a><code class="computeroutput">quantity</code> public construct/copy/destruct</h3> <div class="orderedlist"><ol class="orderedlist" type="1"> <li class="listitem"><pre class="literallayout"><a name="id1403875-bb"></a>quantity();</pre></li> <li class="listitem"><pre class="literallayout"><a name="id1403876-bb"></a>quantity(unspecified_null_pointer_constant_type);</pre></li> <li class="listitem"><pre class="literallayout"><a name="id1403884-bb"></a>quantity(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> & source);</pre></li> <li class="listitem"> <pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> YY> <a name="id1403904-bb"></a>quantity(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit, YY > & source, <span class="emphasis"><em>unspecified</em></span> = 0);</pre>implicit conversion between value types is allowed if allowed for value types themselves </li> <li class="listitem"> <pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> YY> <a name="id1403934-bb"></a>quantity(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit, YY > & source, <span class="emphasis"><em>unspecified</em></span> = 0);</pre>implicit conversion between value types is not allowed if not allowed for value types themselves </li> <li class="listitem"> <pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <a name="id1403986-bb"></a>quantity(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > & source, <span class="emphasis"><em>unspecified</em></span> = 0);</pre>explicit conversion between different unit systems is allowed if implicit conversion is disallowed </li> <li class="listitem"> <pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <a name="id1404021-bb"></a>quantity(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > & source, <span class="emphasis"><em>unspecified</em></span> = 0);</pre>implicit conversion between different unit systems is allowed if each fundamental dimension is implicitly convertible </li> <li class="listitem"><pre class="literallayout"><a name="id1404112-bb"></a>quantity(<span class="bold"><strong>const</strong></span> value_type & val, <span class="bold"><strong>int</strong></span>);</pre></li> <li class="listitem"><pre class="literallayout">quantity& <a name="id1403894-bb"></a><span class="bold"><strong>operator</strong></span>=(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> & source);</pre></li> <li class="listitem"> <pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> YY> quantity& <a name="id1403965-bb"></a><span class="bold"><strong>operator</strong></span>=(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit, YY > & source);</pre>implicit assignment between value types is allowed if allowed for value types themselves </li> <li class="listitem"> <pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> quantity& <a name="id1404056-bb"></a><span class="bold"><strong>operator</strong></span>=(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > & source);</pre>implicit assignment between different unit systems is allowed if each fundamental dimension is implicitly convertible </li> </ol></div> </div> <div class="refsect2" title="quantity private member functions"> <a name="id1951257"></a><h3> <a name="id1403670-bb"></a><code class="computeroutput">quantity</code> private member functions</h3> <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"><span class="type"></span> <a name="id1403674-bb"></a>BOOST_MPL_ASSERT_NOT(<span class="emphasis"><em>unspecified</em></span>) ;</pre></li></ol></div> </div> <div class="refsect2" title="quantity public member functions"> <a name="id1951294"></a><h3> <a name="id1403687-bb"></a><code class="computeroutput">quantity</code> public member functions</h3> <div class="orderedlist"><ol class="orderedlist" type="1"> <li class="listitem"> <pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> value_type &</span> <a name="id1403690-bb"></a>value() <span class="bold"><strong>const</strong></span>;</pre>constant accessor to value <p>can add a quantity of the same type if add_typeof_helper<value_type,value_type>::type is convertible to value_type </p> </li> <li class="listitem"> <pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a name="id1403706-bb"></a><span class="bold"><strong>operator</strong></span>+=(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > & source) ;</pre>can subtract a quantity of the same type if subtract_typeof_helper<value_type,value_type>::type is convertible to value_type </li> <li class="listitem"><pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a name="id1403742-bb"></a><span class="bold"><strong>operator</strong></span>-=(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > & source) ;</pre></li> <li class="listitem"><pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a name="id1403773-bb"></a><span class="bold"><strong>operator</strong></span>*=(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > & source) ;</pre></li> <li class="listitem"> <pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Unit2, <span class="bold"><strong>typename</strong></span> YY> <span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a name="id1403804-bb"></a><span class="bold"><strong>operator</strong></span>/=(<span class="bold"><strong>const</strong></span> <a class="link" href="quantity.html" title="Class template quantity">quantity</a>< Unit2, YY > & source) ;</pre>can multiply a quantity by a scalar value_type if multiply_typeof_helper<value_type,value_type>::type is convertible to value_type </li> <li class="listitem"> <pre class="literallayout"><span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a name="id1403839-bb"></a><span class="bold"><strong>operator</strong></span>*=(<span class="bold"><strong>const</strong></span> value_type & source) ;</pre>can divide a quantity by a scalar value_type if divide_typeof_helper<value_type,value_type>::type is convertible to value_type </li> <li class="listitem"><pre class="literallayout"><span class="type"><a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a> &</span> <a name="id1403859-bb"></a><span class="bold"><strong>operator</strong></span>/=(<span class="bold"><strong>const</strong></span> value_type & source) ;</pre></li> </ol></div> </div> <div class="refsect2" title="quantity public static functions"> <a name="id1951652"></a><h3> <a name="id1404082-bb"></a><code class="computeroutput">quantity</code> public static functions</h3> <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"> <pre class="literallayout"><span class="type"><span class="bold"><strong>static</strong></span> <a class="link" href="quantity.html#boost.units.quantity.this_type">this_type</a></span> <a name="id1404086-bb"></a>from_value(<span class="bold"><strong>const</strong></span> value_type & val) ;</pre>Construct quantity directly from <code class="computeroutput">value_type</code> (potentially dangerous). </li></ol></div> </div> <div class="refsect2" title="Specializations"> <a name="id1951710"></a><h3>Specializations</h3> <div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><a class="link" href="quantity_BOOST_UNITS_DI_id1404125.html" title="Class template quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y>">Class template quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y></a></p></li></ul></div> </div> </div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> <td align="right"><div class="copyright-footer">Copyright © 2003 -2008 Matthias Christian Schabel, 2007-2008 Steven Watanabe<p> Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) </p> </div></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="root.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_units/Reference.html#header.boost.units.quantity_hpp"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="quantity_BOOST_UNITS_DI_id1404125.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a> </div> </body> </html>