1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Class template count</title> 5<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Histogram"> 8<link rel="up" href="../../../histogram/reference.html#header.boost.histogram.accumulators.count_hpp" title="Header <boost/histogram/accumulators/count.hpp>"> 9<link rel="prev" href="../weight_type.html" title="Struct template weight_type"> 10<link rel="next" href="mean.html" title="Class template mean"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="../weight_type.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../histogram/reference.html#header.boost.histogram.accumulators.count_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="mean.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="refentry"> 26<a name="boost.histogram.accumulators.count"></a><div class="titlepage"></div> 27<div class="refnamediv"> 28<h2><span class="refentrytitle">Class template count</span></h2> 29<p>boost::histogram::accumulators::count — Uses a C++ builtin arithmetic type to accumulate a count. </p> 30</div> 31<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> 32<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="../../../histogram/reference.html#header.boost.histogram.accumulators.count_hpp" title="Header <boost/histogram/accumulators/count.hpp>">boost/histogram/accumulators/count.hpp</a>> 33 34</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> ValueType<span class="special">></span> 35<span class="keyword">class</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">{</span> 36<span class="keyword">public</span><span class="special">:</span> 37 <span class="comment">// types</span> 38 <span class="keyword">typedef</span> <span class="identifier">ValueType</span> <a name="boost.histogram.accumulators.count.value_type"></a><span class="identifier">value_type</span><span class="special">;</span> 39 <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <a name="boost.histogram.accumulators.count.const_reference"></a><span class="identifier">const_reference</span><span class="special">;</span> 40 41 <span class="comment">// <a class="link" href="count.html#boost.histogram.accumulators.countconstruct-copy-destruct">construct/copy/destruct</a></span> 42 <a class="link" href="count.html#idm45503931360944-bb"><span class="identifier">count</span></a><span class="special">(</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">default</span><span class="special">;</span> 43 <a class="link" href="count.html#idm45503931360544-bb"><span class="identifier">count</span></a><span class="special">(</span><span class="identifier">const_reference</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span> 44 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">></span> <a class="link" href="count.html#idm45503931359120-bb"><span class="identifier">count</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a><span class="special"><</span> <span class="identifier">T</span> <span class="special">></span> <span class="special">&</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span> 45 46 <span class="comment">// <a class="link" href="count.html#idm45503931397216-bb">public member functions</a></span> 47 <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a class="link" href="count.html#idm45503931396656-bb"><span class="keyword">operator</span><span class="special">++</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span> 48 <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a class="link" href="count.html#idm45503931395104-bb"><span class="keyword">operator</span><span class="special">+=</span></a><span class="special">(</span><span class="identifier">const_reference</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span> 49 <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a class="link" href="count.html#idm45503931392864-bb"><span class="keyword">operator</span><span class="special">+=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span> 50 <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a class="link" href="count.html#idm45503931390192-bb"><span class="keyword">operator</span> <span class="special">*=</span></a><span class="special">(</span><span class="identifier">const_reference</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span> 51 <span class="keyword">bool</span> <a class="link" href="count.html#idm45503931387968-bb"><span class="keyword">operator</span><span class="special">==</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span> 52 <span class="keyword">bool</span> <a class="link" href="count.html#idm45503931385872-bb"><span class="keyword">operator</span><span class="special">!=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span> 53 <span class="identifier">const_reference</span> <a class="link" href="count.html#idm45503931383776-bb"><span class="identifier">value</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span> 54 <span class="keyword">explicit</span> <a class="link" href="count.html#idm45503931382528-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="keyword">noexcept</span><span class="special">;</span> 55 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Archive<span class="special">></span> <span class="keyword">void</span> <a class="link" href="count.html#idm45503931381296-bb"><span class="identifier">serialize</span></a><span class="special">(</span><span class="identifier">Archive</span> <span class="special">&</span><span class="special">,</span> <span class="keyword">unsigned</span><span class="special">)</span><span class="special">;</span> 56 <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a class="link" href="count.html#idm45503931378544-bb"><span class="keyword">operator</span> <span class="special">*=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span> 57 <a class="link" href="count.html" title="Class template count">count</a> <a class="link" href="count.html#idm45503931376160-bb"><span class="keyword">operator</span> <span class="special">*</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span> 58 <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a class="link" href="count.html#idm45503931373936-bb"><span class="keyword">operator</span><span class="special">/=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span> 59 <a class="link" href="count.html" title="Class template count">count</a> <a class="link" href="count.html#idm45503931371552-bb"><span class="keyword">operator</span><span class="special">/</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span> 60 <span class="keyword">bool</span> <a class="link" href="count.html#idm45503931369328-bb"><span class="keyword">operator</span><span class="special"><</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span> 61 <span class="keyword">bool</span> <a class="link" href="count.html#idm45503931367232-bb"><span class="keyword">operator</span><span class="special">></span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span> 62 <span class="keyword">bool</span> <a class="link" href="count.html#idm45503931365136-bb"><span class="keyword">operator</span><span class="special"><=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span> 63 <span class="keyword">bool</span> <a class="link" href="count.html#idm45503931363040-bb"><span class="keyword">operator</span><span class="special">>=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span> 64<span class="special">}</span><span class="special">;</span></pre></div> 65<div class="refsect1"> 66<a name="idm45113196911264"></a><h2>Description</h2> 67<p>This wrapper class may be used as a base class by users who want to add custom metadata to each bin of a histogram. Otherwise, arithmetic types should be used directly as accumulators in storages for simplicity. In other words, prefer <code class="computeroutput">dense_storage<double></code> over<code class="computeroutput">dense_storage<count<double>></code>, both are functionally equivalent.</p> 68<p>When weighted data is accumulated and high precision is required, use <code class="computeroutput"><a class="link" href="sum.html" title="Class template sum">accumulators::sum</a></code> instead. If a local variance estimate for the weight distribution should be computed as well (generally needed for a detailed statistical analysis), use<code class="computeroutput"><a class="link" href="weighted_sum.html" title="Class template weighted_sum">accumulators::weighted_sum</a></code>.</p> 69<div class="refsect2"> 70<a name="idm45113196905808"></a><h3> 71<a name="boost.histogram.accumulators.countconstruct-copy-destruct"></a><code class="computeroutput">count</code> 72 public 73 construct/copy/destruct</h3> 74<div class="orderedlist"><ol class="orderedlist" type="1"> 75<li class="listitem"><pre class="literallayout"><a name="idm45503931360944-bb"></a><span class="identifier">count</span><span class="special">(</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">default</span><span class="special">;</span></pre></li> 76<li class="listitem"> 77<pre class="literallayout"><a name="idm45503931360544-bb"></a><span class="identifier">count</span><span class="special">(</span><span class="identifier">const_reference</span> value<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>Initialize count to value and allow implicit conversion. </li> 78<li class="listitem"> 79<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">></span> <a name="idm45503931359120-bb"></a><span class="identifier">count</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a><span class="special"><</span> <span class="identifier">T</span> <span class="special">></span> <span class="special">&</span> c<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>Allow implicit conversion from other count. </li> 80</ol></div> 81</div> 82<div class="refsect2"> 83<a name="idm45113196882272"></a><h3> 84<a name="idm45503931397216-bb"></a><code class="computeroutput">count</code> public member functions</h3> 85<div class="orderedlist"><ol class="orderedlist" type="1"> 86<li class="listitem"> 87<pre class="literallayout"><a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a name="idm45503931396656-bb"></a><span class="keyword">operator</span><span class="special">++</span><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>Increment count by one. </li> 88<li class="listitem"> 89<pre class="literallayout"><a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a name="idm45503931395104-bb"></a><span class="keyword">operator</span><span class="special">+=</span><span class="special">(</span><span class="identifier">const_reference</span> value<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>Increment count by value. </li> 90<li class="listitem"> 91<pre class="literallayout"><a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a name="idm45503931392864-bb"></a><span class="keyword">operator</span><span class="special">+=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> s<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>Add another count. </li> 92<li class="listitem"> 93<pre class="literallayout"><a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a name="idm45503931390192-bb"></a><span class="keyword">operator</span> <span class="special">*=</span><span class="special">(</span><span class="identifier">const_reference</span> value<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>Scale by value. </li> 94<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="idm45503931387968-bb"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre></li> 95<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="idm45503931385872-bb"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre></li> 96<li class="listitem"> 97<pre class="literallayout"><span class="identifier">const_reference</span> <a name="idm45503931383776-bb"></a><span class="identifier">value</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>Return count. </li> 98<li class="listitem"><pre class="literallayout"><span class="keyword">explicit</span> <a name="idm45503931382528-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="keyword">noexcept</span><span class="special">;</span></pre></li> 99<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Archive<span class="special">></span> <span class="keyword">void</span> <a name="idm45503931381296-bb"></a><span class="identifier">serialize</span><span class="special">(</span><span class="identifier">Archive</span> <span class="special">&</span> ar<span class="special">,</span> <span class="keyword">unsigned</span><span class="special">)</span><span class="special">;</span></pre></li> 100<li class="listitem"><pre class="literallayout"><a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a name="idm45503931378544-bb"></a><span class="keyword">operator</span> <span class="special">*=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre></li> 101<li class="listitem"><pre class="literallayout"><a class="link" href="count.html" title="Class template count">count</a> <a name="idm45503931376160-bb"></a><span class="keyword">operator</span> <span class="special">*</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre></li> 102<li class="listitem"><pre class="literallayout"><a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> <a name="idm45503931373936-bb"></a><span class="keyword">operator</span><span class="special">/=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre></li> 103<li class="listitem"><pre class="literallayout"><a class="link" href="count.html" title="Class template count">count</a> <a name="idm45503931371552-bb"></a><span class="keyword">operator</span><span class="special">/</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre></li> 104<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="idm45503931369328-bb"></a><span class="keyword">operator</span><span class="special"><</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre></li> 105<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="idm45503931367232-bb"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre></li> 106<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="idm45503931365136-bb"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre></li> 107<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="idm45503931363040-bb"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="count.html" title="Class template count">count</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre></li> 108</ol></div> 109</div> 110</div> 111</div> 112<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 113<td align="left"></td> 114<td align="right"><div class="copyright-footer">Copyright © 2016-2019 Hans 115 Dembinski<p> 116 Distributed under the Boost Software License, Version 1.0. (See accompanying 117 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 118 </p> 119</div></td> 120</tr></table> 121<hr> 122<div class="spirit-nav"> 123<a accesskey="p" href="../weight_type.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../histogram/reference.html#header.boost.histogram.accumulators.count_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="mean.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 124</div> 125</body> 126</html> 127