Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use a phoenix expression with boost::transform_iterator?
    primarykey
    data
    text
    <p><strong>&lt;Update&gt;</strong> As usual for me, the question was a wrong one. The actual question is: why doesn't transform_iterator use the conventional result_of&lt;> metafunction to determine the return type, instead of accessing UnaryFunc::result_type directly. Posted an answer with a work around. <strong>&lt;/Update&gt;</strong></p> <p>Specifically, is there a way to make a phoenix expression expose a <code>result_type</code> type as expected for the std::unary_function concept? boost::transform_iterator seems to expect this, and from looking at the src of it, I don't see a simple work around. </p> <p>Here's some code that reproduces the problem I've been having:</p> <pre><code>#include &lt;boost/iterator/transform_iterator.hpp&gt; #include &lt;boost/spirit/home/phoenix.hpp&gt; #include &lt;numeric&gt; #include &lt;iostream&gt; using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int main(void){ int i[] = {4,2,5,3}; std::cout &lt;&lt; std::accumulate( boost::make_transform_iterator(i, _1*_1), boost::make_transform_iterator(i+4, _1*_1), 0 ) &lt;&lt; std::endl; return 0; } </code></pre> <p>The relavent portion of the error message from compiling this is (gcc 4.3.4, boost 1.43):</p> <pre><code>/usr/include/boost/iterator/transform_iterator.hpp:43: error: no type named ‘result_type’ in ‘struct boost::phoenix::actor&lt;... </code></pre> <p>I have the same problem with boost::lambda (missing <code>result_type</code>). I thought that I had seen similar usage for make_transform_iterator and lambda in the past, now I'm wondering if I just imagined it.</p> <p>Is there a provided wrapper or some other mechanism in phoenix or lambda to expose <code>result_type</code>? </p>
    singulars
    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. 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