Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sure <code>rolling_count_non_zero</code> sounds like an appropriate name for what you want (although it could have been somewhat more generic, maybe <code>rolling_count_if</code>?).</p> <p><a href="http://www.boost.org/doc/libs/release/doc/html/accumulators/user_s_guide.html" rel="nofollow">Boost.accumulators users guide</a> describes how to write your own accumulators, features, and extractors, simply following that description, the following seems to work:</p> <pre><code>namespace boost { namespace accumulators { namespace impl { template&lt;typename Sample&gt; struct rolling_count_non_zero : accumulator_base { typedef std::size_t result_type; rolling_count_non_zero(dont_care) : cnt_() {} template&lt;typename Args&gt; void operator ()(Args const &amp;args) { if(args[sample] != 0) ++cnt_; if(is_rolling_window_plus1_full(args) &amp;&amp; rolling_window_plus1(args).front() != 0 ) --cnt_; } template&lt;typename Args&gt; result_type result(Args const &amp;args) const { return cnt_; } private: std::size_t cnt_; }; } namespace tag { struct rolling_count_non_zero : depends_on&lt; rolling_window_plus1 &gt; { typedef accumulators::impl::rolling_count_non_zero&lt; mpl::_1 &gt; impl; }; } namespace extract { extractor&lt;tag::rolling_count_non_zero&gt; const rolling_count_non_zero = {}; } using extract::rolling_count_non_zero; }} </code></pre> <p>live demo: <a href="http://coliru.stacked-crooked.com/a/bc4bea090690f26d" rel="nofollow">http://coliru.stacked-crooked.com/a/bc4bea090690f26d</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload