Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are two immediate problems with your code:</p> <ul> <li><p>you compute <code>fusion::as_nview&lt;N&gt;(*it)</code> and try to store it as if it were a <code>fusion::result_of::as_nview&lt;T::value_type, N&gt;::type</code>; in truth it is a <code>fusion::result_of::as_nview&lt;T::value_type const, N&gt;::type</code> (<code>*it</code> has type <code>T::const_reference</code>); this is the source of your <code>const</code>-related errors.</p></li> <li><p>you try to accumulate the resulting views, but, as far I can tell from <a href="http://www.boost.org/doc/libs/1_52_0/libs/fusion/doc/html/fusion/view/nview.html" rel="nofollow">the Fusion docs</a>, valid operations on such a view are mostly those of a Fusion Random Access Sequence. In particular you can't add two views together, or default construct one. Here's a lead to a possible fix (by no means the only way though), not actually tested:</p> <pre><code>typedef typename Container::value_type view_type; typedef typename fusion::result_of::at_c&lt;view_type, 0&gt;::type reference; // boost::decay is from Boost.TypeTraits typedef typename boost::decay&lt;reference&gt;::type value_type; value_type zero = 0; return std::accumulate(container.begin(), container.end(), zero, add_views()); </code></pre> <p>where <code>add_views</code> is a functor that returns something in the spirit of <code>lhs + at&lt;0&gt;(rhs)</code>. Note that this solution only really makes sense if you intend for <code>c</code> to make views of length exactly one.</p></li> </ul>
 

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