• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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=UTF-8">
5<title>Class template constrained_value</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.constrained_value_hpp" title="Header &lt;boost/date_time/constrained_value.hpp&gt;">
10<link rel="prev" href="../date_time/c_time.html" title="Struct c_time">
11<link rel="next" href="simple_exception_policy.html" title="Class template simple_exception_policy">
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="../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>
25</div>
26<div class="refentry">
27<a name="boost.CV.constrained_value"></a><div class="titlepage"></div>
28<div class="refnamediv">
29<h2><span class="refentrytitle">Class template constrained_value</span></h2>
30<p>boost::CV::constrained_value — A template to specify a constrained basic value 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.constrained_value_hpp" title="Header &lt;boost/date_time/constrained_value.hpp&gt;">boost/date_time/constrained_value.hpp</a>&gt;
34
35</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> value_policies<span class="special">&gt;</span>
36<span class="keyword">class</span> <a class="link" href="constrained_value.html" title="Class template constrained_value">constrained_value</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">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>
40
41  <span class="comment">// <a class="link" href="constrained_value.html#boost.CV.constrained_valueconstruct-copy-destruct">construct/copy/destruct</a></span>
42  <a class="link" href="constrained_value.html#id-1_3_14_15_3_6_1_1_1_6-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>
43  <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <a class="link" href="constrained_value.html" title="Class template constrained_value">constrained_value</a> <span class="special">&amp;</span> <a class="link" href="constrained_value.html#id-1_3_14_15_3_6_1_1_1_7-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>
44
45  <span class="comment">// <a class="link" href="constrained_value.html#id-1_3_14_15_3_6_1_1_1_5-bb">public member functions</a></span>
46  <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <a class="link" href="constrained_value.html#id-1_3_14_15_3_6_1_1_1_5_1-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>
47
48  <span class="comment">// <a class="link" href="constrained_value.html#id-1_3_14_15_3_6_1_1_1_8-bb">public static functions</a></span>
49  <span class="keyword">static</span> <span class="identifier">BOOST_CONSTEXPR</span> <span class="identifier">value_type</span> <span class="identifier">max</span> <a class="link" href="constrained_value.html#id-1_3_14_15_3_6_1_1_1_8_1-bb"><span class="identifier">BOOST_PREVENT_MACRO_SUBSTITUTION</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
50  <span class="keyword">static</span> <span class="identifier">BOOST_CONSTEXPR</span> <span class="identifier">value_type</span> <span class="identifier">min</span> <a class="link" href="constrained_value.html#id-1_3_14_15_3_6_1_1_1_8_2-bb"><span class="identifier">BOOST_PREVENT_MACRO_SUBSTITUTION</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
51
52  <span class="comment">// <a class="link" href="constrained_value.html#id-1_3_14_15_3_6_1_1_1_9-bb">private member functions</a></span>
53  <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="keyword">void</span> <a class="link" href="constrained_value.html#id-1_3_14_15_3_6_1_1_1_9_1-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>
54<span class="special">}</span><span class="special">;</span></pre></div>
55<div class="refsect1">
56<a name="id-1.3.14.15.3.6.3.4"></a><h2>Description</h2>
57<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>
58<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>
59<div class="refsect2">
60<a name="id-1.3.14.15.3.6.3.4.4"></a><h3>
61<a name="boost.CV.constrained_valueconstruct-copy-destruct"></a><code class="computeroutput">constrained_value</code>
62        public
63       construct/copy/destruct</h3>
64<div class="orderedlist"><ol class="orderedlist" type="1">
65<li class="listitem"><pre class="literallayout"><a name="id-1_3_14_15_3_6_1_1_1_6-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>
66<li class="listitem"><pre class="literallayout"><span class="identifier">BOOST_CXX14_CONSTEXPR</span> <a class="link" href="constrained_value.html" title="Class template constrained_value">constrained_value</a> <span class="special">&amp;</span> <a name="id-1_3_14_15_3_6_1_1_1_7-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>
67</ol></div>
68</div>
69<div class="refsect2">
70<a name="id-1.3.14.15.3.6.3.4.5"></a><h3>
71<a name="id-1_3_14_15_3_6_1_1_1_5-bb"></a><code class="computeroutput">constrained_value</code> public member functions</h3>
72<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
73<pre class="literallayout"><span class="identifier">BOOST_CXX14_CONSTEXPR</span> <a name="id-1_3_14_15_3_6_1_1_1_5_1-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>
74</div>
75<div class="refsect2">
76<a name="id-1.3.14.15.3.6.3.4.6"></a><h3>
77<a name="id-1_3_14_15_3_6_1_1_1_8-bb"></a><code class="computeroutput">constrained_value</code> public static functions</h3>
78<div class="orderedlist"><ol class="orderedlist" type="1">
79<li class="listitem">
80<pre class="literallayout"><span class="keyword">static</span> <span class="identifier">BOOST_CONSTEXPR</span> <span class="identifier">value_type</span> <span class="identifier">max</span> <a name="id-1_3_14_15_3_6_1_1_1_8_1-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>
81<li class="listitem">
82<pre class="literallayout"><span class="keyword">static</span> <span class="identifier">BOOST_CONSTEXPR</span> <span class="identifier">value_type</span> <span class="identifier">min</span> <a name="id-1_3_14_15_3_6_1_1_1_8_2-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>
83</ol></div>
84</div>
85<div class="refsect2">
86<a name="id-1.3.14.15.3.6.3.4.7"></a><h3>
87<a name="id-1_3_14_15_3_6_1_1_1_9-bb"></a><code class="computeroutput">constrained_value</code> private member functions</h3>
88<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"><span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="keyword">void</span> <a name="id-1_3_14_15_3_6_1_1_1_9_1-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>
89</div>
90</div>
91</div>
92<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
93<td align="left"></td>
94<td align="right"><div class="copyright-footer">Copyright © 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
95    <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>
96</div></td>
97</tr></table>
98<hr>
99<div class="spirit-nav">
100<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>
101</div>
102</body>
103</html>
104