Boost C++ Libraries: Ticket #963: typeof: nested types of BOOST_TYPEOF'ed type don't work on gcc 3.4.5 in native mode https://svn.boost.org/trac10/ticket/963 <p> Example: </p> <pre class="wiki">#include &lt;boost/typeof/typeof.hpp&gt; #include &lt;boost/typeof/std/vector.hpp&gt; BOOST_TYPEOF_REGISTER_TYPE(std::vector&lt;int&gt;::iterator) BOOST_TYPEOF_REGISTER_TYPE(std::vector&lt;int&gt;::const_iterator) int main(int argc, char** argv) { std::vector&lt;int&gt; v; BOOST_TYPEOF(v)::iterator i = v.begin(); return 0; } </pre><p> Results in an error on gcc-3.4.5 </p> <pre class="wiki">1.cpp:9: error: expected initializer before "i" </pre><p> This is because apparently you can't do typeof(v)::type in gcc 3.4.5. Workaround is very simple, but maybe it's better if this is implemented in boost.typeof itself: </p> <pre class="wiki">#include &lt;boost/typeof/typeof.hpp&gt; #include &lt;boost/typeof/std/vector.hpp&gt; BOOST_TYPEOF_REGISTER_TYPE(std::vector&lt;int&gt;::iterator) BOOST_TYPEOF_REGISTER_TYPE(std::vector&lt;int&gt;::const_iterator) template&lt;typename T&gt; struct ut_type_mirror { typedef T type; }; #define UT_TYPEOF(v) ut_type_mirror&lt;BOOST_TYPEOF(v)&gt;::type int main(int argc, char** argv) { std::vector&lt;int&gt; v; UT_TYPEOF(v)::iterator i = v.begin(); return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/963 Trac 1.4.3 Peder Holt Fri, 06 Jul 2007 15:43:59 GMT owner, severity set https://svn.boost.org/trac10/ticket/963#comment:1 https://svn.boost.org/trac10/ticket/963#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Peder Holt</span> </li> <li><strong>severity</strong> → <span class="trac-field-new">Showstopper</span> </li> </ul> Ticket Peder Holt Fri, 06 Jul 2007 18:05:48 GMT status, severity changed; resolution set https://svn.boost.org/trac10/ticket/963#comment:2 https://svn.boost.org/trac10/ticket/963#comment:2 <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> <li><strong>severity</strong> <span class="trac-field-old">Showstopper</span> → <span class="trac-field-new">Problem</span> </li> </ul> <p> The above solution was tested and rejected for the following reason: GCC 3.3.3 (which we probably want to support) ICEs if <code>__typeof__</code> is wrapped into anything while inside a template: </p> <div class="wiki-code"><div class="code"><pre> <span class="k">typedef</span> <span class="n">mpl</span><span class="o">::</span><span class="n">identity</span><span class="o">&lt;</span><span class="n">__typeof__</span><span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">)</span><span class="o">&gt;::</span><span class="n">type</span> <span class="n">type</span><span class="p">;</span> <span class="c1">// OK</span> <span class="k">template</span><span class="o">&lt;</span><span class="k">class</span> <span class="nc">T</span><span class="o">&gt;</span> <span class="k">class</span> <span class="nc">A</span> <span class="p">{</span> <span class="k">typedef</span> <span class="n">__typeof__</span><span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">)</span> <span class="n">type</span><span class="p">;</span> <span class="c1">// OK</span> <span class="k">typedef</span> <span class="n">mpl</span><span class="o">::</span><span class="n">identity</span><span class="o">&lt;</span><span class="n">__typeof__</span><span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">)</span><span class="o">&gt;::</span><span class="n">type</span> <span class="n">type</span><span class="p">;</span> <span class="c1">// ICE</span> <span class="p">};</span> </pre></div></div> Ticket