Boost C++ Libraries: Ticket #5811: indirected range adaptor not satisfied with unary dereference operator https://svn.boost.org/trac10/ticket/5811 <p> The documentation for Range's indirected adaptor claims that it is usable with anything that has an unary operator*(). </p> <p> When using it with a range of optional&lt;int&gt;, it seems to require an element_type inner type, which optional doesn't expose and the docs does not require. </p> <p> The following testcase fails to compile with VC10 and GCC 4.2.3: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/optional.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/adaptors.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;vector&gt;</span><span class="cp"></span> <span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span><span class="o">*</span> <span class="n">argv</span><span class="p">[])</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">boost</span><span class="o">::</span><span class="n">optional</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="o">&gt;</span> <span class="n">v</span><span class="p">;</span> <span class="n">v</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">indirected</span><span class="p">;</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5811 Trac 1.4.3 Lars Viklund <zao@…> Tue, 30 Aug 2011 15:35:42 GMT <link>https://svn.boost.org/trac10/ticket/5811#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5811#comment:1</guid> <description> <p> This was apparently known back in May in a <a class="ext-link" href="http://stackoverflow.com/questions/6123327/use-boostoptional-together-with-boostadaptorsindirected"><span class="icon">​</span>question on Stack Overflow</a>, which also mentions a workaround for Boost.Optional. It doesn't address the underlying doc bug though, so the ticket is still valid. </p> <pre class="wiki">#include &lt;boost/optional/optional_fwd.hpp&gt; #include &lt;boost/pointee.hpp&gt; namespace boost { template&lt;typename P&gt; struct pointee&lt;optional&lt;P&gt; &gt; { typedef typename optional&lt;P&gt;::value_type type; }; } </pre> </description> <category>Ticket</category> </item> <item> <author>Júlio Hoffimann Mendes <julio.hoffimann@…></author> <pubDate>Tue, 30 Aug 2011 15:59:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5811#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5811#comment:2</guid> <description> <p> I found this related topic on stackoverflow: </p> <p> <a class="ext-link" href="http://stackoverflow.com/questions/6123327/use-boostoptional-together-with-boostadaptorsindirected"><span class="icon">​</span>http://stackoverflow.com/questions/6123327/use-boostoptional-together-with-boostadaptorsindirected</a> </p> <p> The first answer solved the problem for me, i don't know if it's safe though. </p> <p> Regards, Júlio. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Neil Groves</dc:creator> <pubDate>Sat, 22 Feb 2014 16:18:33 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5811#comment:3 https://svn.boost.org/trac10/ticket/5811#comment:3 <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">fixed</span> </li> </ul> <p> Added a unit test to confirm that a fix has been made to Boost.Optional and that the use-case now works as expected when using optional with the indirected adapter. </p> Ticket rob.desbois@… Tue, 24 Oct 2017 11:58:04 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/5811#comment:4 https://svn.boost.org/trac10/ticket/5811#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> This doesn't appear to be fixed; I've tried the testcase using the latest Boost (1.65.1) with both clang 4.01 and gcc 6.4.1, but still get the compilation failure: </p> <pre class="wiki">boost_1_65_1/boost/pointee.hpp:30:27: error: no type named 'element_type' in 'boost::optional&lt;int&gt;' </pre> Ticket