blob: 0cc568f66e381f6a2381ef2ece4fe2bab30927f0 [file] [log] [blame]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Class template constrained_value</title>
<link rel="stylesheet" href="../../../../doc/src/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="../../date_time/doxy.html#header.boost.date_time.constrained_value_hpp" title="Header &lt;boost/date_time/constrained_value.hpp&gt;">
<link rel="prev" href="../date_time/c_time.html" title="Struct c_time">
<link rel="next" href="simple_exception_policy.html" title="Class template simple_exception_policy">
</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="../date_time/c_time.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.constrained_value_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="simple_exception_policy.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.CV.constrained_value"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template constrained_value</span></h2>
<p>boost::CV::constrained_value &#8212; A template to specify a constrained basic value type. </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="comment">// In header: &lt;<a class="link" href="../../date_time/doxy.html#header.boost.date_time.constrained_value_hpp" title="Header &lt;boost/date_time/constrained_value.hpp&gt;">boost/date_time/constrained_value.hpp</a>&gt;
</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> value_policies<span class="special">&gt;</span>
<span class="keyword">class</span> <a class="link" href="constrained_value.html" title="Class template constrained_value">constrained_value</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
<span class="comment">// types</span>
<span class="keyword">typedef</span> <span class="identifier">value_policies</span><span class="special">::</span><span class="identifier">value_type</span> <a name="boost.CV.constrained_value.value_type"></a><span class="identifier">value_type</span><span class="special">;</span>
<span class="comment">// <a class="link" href="constrained_value.html#boost.CV.constrained_valueconstruct-copy-destruct">construct/copy/destruct</a></span>
<a class="link" href="constrained_value.html#id598479-bb"><span class="identifier">constrained_value</span></a><span class="special">(</span><span class="identifier">value_type</span><span class="special">)</span><span class="special">;</span>
constrained_value&amp; <a class="link" href="constrained_value.html#id598486-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="identifier">value_type</span><span class="special">)</span><span class="special">;</span>
<span class="comment">// <a class="link" href="constrained_value.html#id598465-bb">public member functions</a></span>
<a class="link" href="constrained_value.html#id598468-bb"><span class="keyword">operator</span> <span class="identifier">value_type</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="comment">// <a class="link" href="constrained_value.html#id598493-bb">public static functions</a></span>
<span class="keyword">static</span> <span class="identifier">value_type</span> <span class="identifier">max</span> <a class="link" href="constrained_value.html#id598496-bb"><span class="identifier">BOOST_PREVENT_MACRO_SUBSTITUTION</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
<span class="keyword">static</span> <span class="identifier">value_type</span> <span class="identifier">min</span> <a class="link" href="constrained_value.html#id598508-bb"><span class="identifier">BOOST_PREVENT_MACRO_SUBSTITUTION</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
<span class="comment">// <a class="link" href="constrained_value.html#id598519-bb">private member functions</a></span>
<span class="keyword">void</span> <a class="link" href="constrained_value.html#id598522-bb"><span class="identifier">assign</span></a><span class="special">(</span><span class="identifier">value_type</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id1060991"></a><h2>Description</h2>
<p>This template provides a quick way to generate an integer type with a constrained range. The type provides for the ability to specify the min, max, and and error handling policy.</p>
<p><span class="bold"><strong>value policies</strong></span> A class that provides the range limits via the min and max functions as well as a function on_error that determines how errors are handled. A common strategy would be to assert or throw and exception. The on_error is passed both the current value and the new value that is in error. </p>
<div class="refsect2">
<a name="id1061011"></a><h3>
<a name="boost.CV.constrained_valueconstruct-copy-destruct"></a><code class="computeroutput">constrained_value</code>
public
construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><pre class="literallayout"><a name="id598479-bb"></a><span class="identifier">constrained_value</span><span class="special">(</span><span class="identifier">value_type</span> value<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout">constrained_value&amp; <a name="id598486-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="identifier">value_type</span> v<span class="special">)</span><span class="special">;</span></pre></li>
</ol></div>
</div>
<div class="refsect2">
<a name="id1061107"></a><h3>
<a name="id598465-bb"></a><code class="computeroutput">constrained_value</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><a name="id598468-bb"></a><span class="keyword">operator</span> <span class="identifier">value_type</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Coerce into the representation type. </li></ol></div>
</div>
<div class="refsect2">
<a name="id1061168"></a><h3>
<a name="id598493-bb"></a><code class="computeroutput">constrained_value</code> public static functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">static</span> <span class="identifier">value_type</span> <span class="identifier">max</span> <a name="id598496-bb"></a><span class="identifier">BOOST_PREVENT_MACRO_SUBSTITUTION</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Return the max allowed value (traits method). </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">static</span> <span class="identifier">value_type</span> <span class="identifier">min</span> <a name="id598508-bb"></a><span class="identifier">BOOST_PREVENT_MACRO_SUBSTITUTION</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Return the min allowed value (traits method). </li>
</ol></div>
</div>
<div class="refsect2">
<a name="id1061281"></a><h3>
<a name="id598519-bb"></a><code class="computeroutput">constrained_value</code> private member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="id598522-bb"></a><span class="identifier">assign</span><span class="special">(</span><span class="identifier">value_type</span> value<span class="special">)</span><span class="special">;</span></pre></li></ol></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 &#169; 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
<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>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../date_time/c_time.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.constrained_value_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="simple_exception_policy.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>