Boost C++ Libraries: Ticket #6172: let ::boost:: adaptors:: transformed accept raw function pointers too https://svn.boost.org/trac10/ticket/6172 <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;cstdlib&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;vector&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/algorithm/find.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/adaptor/transformed.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/mem_fn.hpp&gt;</span><span class="cp"></span> <span class="k">class</span> <span class="nc">X</span> <span class="p">{</span> <span class="k">public</span><span class="o">:</span> <span class="kt">int</span> <span class="n">foo</span> <span class="p">()</span> <span class="k">const</span><span class="p">;</span> <span class="p">};</span> <span class="cp">#define MEM_FN </span> <span class="cp">#ifndef MEM_FN</span> <span class="cp">#define MEM_FN ::boost:: mem_fn </span> <span class="cp">#endif</span> <span class="kt">int</span> <span class="nf">main</span> <span class="p">()</span> <span class="p">{</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span> <span class="n">find</span> <span class="p">(</span><span class="o">::</span><span class="n">std</span><span class="o">::</span> <span class="n">vector</span> <span class="o">&lt;</span> <span class="n">X</span> <span class="o">&gt;</span> <span class="p">()</span> <span class="o">|</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span> <span class="n">adaptors</span><span class="o">::</span> <span class="n">transformed</span> <span class="p">(</span><span class="n">MEM_FN</span> <span class="p">(</span><span class="o">&amp;</span><span class="n">X</span><span class="o">::</span> <span class="n">foo</span><span class="p">)),</span> <span class="mi">0</span><span class="p">);</span> <span class="k">return</span> <span class="o">+</span><span class="n">EXIT_SUCCESS</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><blockquote> <p> /usr/include/boost/iterator/transform_iterator.hpp:42:47: error: ‘int (X::*)()const’ is not a class, struct, or union type </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6172 Trac 1.4.3 Neil Groves Sun, 09 Mar 2014 21:51:31 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6172#comment:1 https://svn.boost.org/trac10/ticket/6172#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> There is an easier solution that already works. If you just use boost::bind(&amp;X::foo, _1) instead of the MEM_FN macro it works. This also works everywhere else in Boost.Range it accepts a functor without requiring a combinatorial explosion of function overloads. </p> Ticket