Boost C++ Libraries: Ticket #4337: info.hpp: unnecessary (?) temporary shared_ptr<error_info_base const> https://svn.boost.org/trac10/ticket/4337 <p> It seems to me that the creation of a temporary shared_ptr&lt;error_info_base const&gt; object at <a class="ext-link" href="https://svn.boost.org/trac/boost/browser/trunk/boost/exception/info.hpp?rev=61602#L117"><span class="icon">​</span>info.hpp line 117</a> is unnecessary: </p> <pre class="wiki"> shared_ptr&lt;error_info_base const&gt; const &amp; x = i-&gt;second; </pre><p> In the quoted code above, a temporary copy of i-&gt;second must be created, because i-&gt;second itself is a non-const shared_ptr&lt;error_info_base&gt;. It seems to me that this temporary copy can be avoided easily by removing the inner const from the type of x: </p> <pre class="wiki"> shared_ptr&lt;error_info_base&gt; const &amp; x = i-&gt;second; </pre><p> Or by declaring x as a raw pointer: </p> <pre class="wiki"> error_info_base const * const x = i-&gt;second.get(); </pre><p> What do you think? </p> <p> FYI, this line of code drew my attention, because of a Codegear warning: </p> <pre class="wiki">Warning W8028 ..\..\..\boost/exception/info.hpp 117: Temporary used to initialize 'x' in function error_info_container_impl::diagnostic_information(const char *) const </pre><p> Each of the two suggested changes would fix the warning. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4337 Trac 1.4.3 Emil Dotchevski Sun, 13 Jun 2010 02:36:11 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4337#comment:1 https://svn.boost.org/trac10/ticket/4337#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">fixed</span> </li> </ul> <p> Thanks, fixed in trunk revision 62892. </p> Ticket