Imported Upstream version 1.64.0
[platform/upstream/boost.git] / doc / html / boost / date_time / wrapping_int.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>Class template wrapping_int</title>
6 <link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
7 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8 <link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9 <link rel="up" href="../../date_time/doxy.html#header.boost.date_time.wrapping_int_hpp" title="Header &lt;boost/date_time/wrapping_int.hpp&gt;">
10 <link rel="prev" href="tz_db_base.html" title="Class template tz_db_base">
11 <link rel="next" href="wrapping_int2.html" title="Class template wrapping_int2">
12 </head>
13 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14 <table cellpadding="2" width="100%"><tr>
15 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
16 <td align="center"><a href="../../../../index.html">Home</a></td>
17 <td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
18 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20 <td align="center"><a href="../../../../more/index.htm">More</a></td>
21 </tr></table>
22 <hr>
23 <div class="spirit-nav">
24 <a accesskey="p" href="tz_db_base.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.wrapping_int_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="wrapping_int2.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
25 </div>
26 <div class="refentry">
27 <a name="boost.date_time.wrapping_int"></a><div class="titlepage"></div>
28 <div class="refnamediv">
29 <h2><span class="refentrytitle">Class template wrapping_int</span></h2>
30 <p>boost::date_time::wrapping_int &#8212; A wrapping integer used to support time durations (WARNING: only instantiate with a signed type) </p>
31 </div>
32 <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
33 <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../date_time/doxy.html#header.boost.date_time.wrapping_int_hpp" title="Header &lt;boost/date_time/wrapping_int.hpp&gt;">boost/date_time/wrapping_int.hpp</a>&gt;
34
35 </span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> int_type_<span class="special">,</span> <span class="identifier">int_type_</span> wrap_val<span class="special">&gt;</span> 
36 <span class="keyword">class</span> <a class="link" href="wrapping_int.html" title="Class template wrapping_int">wrapping_int</a> <span class="special">{</span>
37 <span class="keyword">public</span><span class="special">:</span>
38   <span class="comment">// types</span>
39   <span class="keyword">typedef</span> <span class="identifier">int_type_</span> <a name="boost.date_time.wrapping_int.int_type"></a><span class="identifier">int_type</span><span class="special">;</span>
40
41   <span class="comment">// <a class="link" href="wrapping_int.html#boost.date_time.wrapping_intconstruct-copy-destruct">construct/copy/destruct</a></span>
42   <a class="link" href="wrapping_int.html#idp497726464-bb"><span class="identifier">wrapping_int</span></a><span class="special">(</span><span class="identifier">int_type</span><span class="special">)</span><span class="special">;</span>
43
44   <span class="comment">// <a class="link" href="wrapping_int.html#idp497714560-bb">public static functions</a></span>
45   <span class="keyword">static</span> <span class="identifier">int_type</span> <a class="link" href="wrapping_int.html#idp497715120-bb"><span class="identifier">wrap_value</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
46
47   <span class="comment">// <a class="link" href="wrapping_int.html#idp497716400-bb">public member functions</a></span>
48   <span class="identifier">int_type</span> <a class="link" href="wrapping_int.html#idp497716960-bb"><span class="identifier">as_int</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
49   <a class="link" href="wrapping_int.html#idp497718384-bb"><span class="keyword">operator</span> <span class="identifier">int_type</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
50   <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">IntT</span> <a class="link" href="wrapping_int.html#idp497719504-bb"><span class="identifier">add</span></a><span class="special">(</span><span class="identifier">IntT</span><span class="special">)</span><span class="special">;</span>
51   <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">IntT</span> <a class="link" href="wrapping_int.html#idp497722848-bb"><span class="identifier">subtract</span></a><span class="special">(</span><span class="identifier">IntT</span><span class="special">)</span><span class="special">;</span>
52
53   <span class="comment">// <a class="link" href="wrapping_int.html#idp497727744-bb">private member functions</a></span>
54   <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">IntT</span> <a class="link" href="wrapping_int.html#idp497728320-bb"><span class="identifier">calculate_wrap</span></a><span class="special">(</span><span class="identifier">IntT</span><span class="special">)</span><span class="special">;</span>
55 <span class="special">}</span><span class="special">;</span></pre></div>
56 <div class="refsect1">
57 <a name="idp232215856"></a><h2>Description</h2>
58 <p>In composite date and time types this type is used to wrap at the day boundary. Ex: A wrapping_int&lt;short, 10&gt; will roll over after nine, and roll under below zero. This gives a range of [0,9]</p>
59 <p>NOTE: it is strongly recommended that <a class="link" href="wrapping_int2.html" title="Class template wrapping_int2">wrapping_int2</a> be used instead of <a class="link" href="wrapping_int.html" title="Class template wrapping_int">wrapping_int</a> as <a class="link" href="wrapping_int.html" title="Class template wrapping_int">wrapping_int</a> is to be depricated at some point soon.</p>
60 <p>Also Note that warnings will occur if instantiated with an unsigned type. Only a signed type should be used! </p>
61 <div class="refsect2">
62 <a name="idp232220096"></a><h3>
63 <a name="boost.date_time.wrapping_intconstruct-copy-destruct"></a><code class="computeroutput">wrapping_int</code> 
64         public
65        construct/copy/destruct</h3>
66 <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
67 <pre class="literallayout"><a name="idp497726464-bb"></a><span class="identifier">wrapping_int</span><span class="special">(</span><span class="identifier">int_type</span> v<span class="special">)</span><span class="special">;</span></pre>Add, return true if wrapped. </li></ol></div>
68 </div>
69 <div class="refsect2">
70 <a name="idp232226720"></a><h3>
71 <a name="idp497714560-bb"></a><code class="computeroutput">wrapping_int</code> public static functions</h3>
72 <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">int_type</span> <a name="idp497715120-bb"></a><span class="identifier">wrap_value</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li></ol></div>
73 </div>
74 <div class="refsect2">
75 <a name="idp232233824"></a><h3>
76 <a name="idp497716400-bb"></a><code class="computeroutput">wrapping_int</code> public member functions</h3>
77 <div class="orderedlist"><ol class="orderedlist" type="1">
78 <li class="listitem">
79 <pre class="literallayout"><span class="identifier">int_type</span> <a name="idp497716960-bb"></a><span class="identifier">as_int</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Explicit converion method. </li>
80 <li class="listitem"><pre class="literallayout"><a name="idp497718384-bb"></a><span class="keyword">operator</span> <span class="identifier">int_type</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
81 <li class="listitem">
82 <pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">IntT</span> <a name="idp497719504-bb"></a><span class="identifier">add</span><span class="special">(</span><span class="identifier">IntT</span> v<span class="special">)</span><span class="special">;</span></pre>Add, return number of wraps performed. <p>The sign of the returned value will indicate which direction the wraps went. Ex: add a negative number and wrapping under could occur, this would be indicated by a negative return value. If wrapping over took place, a positive value would be returned </p>
83 </li>
84 <li class="listitem">
85 <pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">IntT</span> <a name="idp497722848-bb"></a><span class="identifier">subtract</span><span class="special">(</span><span class="identifier">IntT</span> v<span class="special">)</span><span class="special">;</span></pre>Subtract will return '+d' if wrapping under took place ('d' is the number of wraps) <p>The sign of the returned value will indicate which direction the wraps went (positive indicates wrap under, negative indicates wrap over). Ex: subtract a negative number and wrapping over could occur, this would be indicated by a negative return value. If wrapping under took place, a positive value would be returned. </p>
86 </li>
87 </ol></div>
88 </div>
89 <div class="refsect2">
90 <a name="idp232262608"></a><h3>
91 <a name="idp497727744-bb"></a><code class="computeroutput">wrapping_int</code> private member functions</h3>
92 <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">IntT</span> <a name="idp497728320-bb"></a><span class="identifier">calculate_wrap</span><span class="special">(</span><span class="identifier">IntT</span> wrap<span class="special">)</span><span class="special">;</span></pre></li></ol></div>
93 </div>
94 </div>
95 </div>
96 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
97 <td align="left"></td>
98 <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
99     <code class="filename">LICENSE_1_0.txt</code> 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>
100 </div></td>
101 </tr></table>
102 <hr>
103 <div class="spirit-nav">
104 <a accesskey="p" href="tz_db_base.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.wrapping_int_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="wrapping_int2.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
105 </div>
106 </body>
107 </html>