Subject: [Boost-bugs] [Boost C++ Libraries] #4337: info.hpp: unnecessary (?) temporary shared_ptr<error_info_base const>
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-06-13 01:02:36
#4337: info.hpp: unnecessary (?) temporary shared_ptr<error_info_base const>
--------------------------+-------------------------------------------------
Reporter: niels_dekker | Owner: emildotchevski
Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: exception
Version: Boost 1.44.0 | Severity: Optimization
Keywords: |
--------------------------+-------------------------------------------------
It seems to me that the creation of a temporary shared_ptr<error_info_base
const> object at
[https://svn.boost.org/trac/boost/browser/trunk/boost/exception/info.hpp?rev=61602#L117
info.hpp line 117] is unnecessary:
{{{
shared_ptr<error_info_base const> const & x = i->second;
}}}
In the quoted code above, a temporary copy of i->second must be created,
because i->second itself is a non-const shared_ptr<error_info_base>. It
seems to me that this temporary copy can be avoided easily by removing the
inner const from the type of x:
{{{
shared_ptr<error_info_base> const & x = i->second;
}}}
Or by declaring x as a raw pointer:
{{{
error_info_base const * const x = i->second.get();
}}}
What do you think?
FYI, this line of code drew my attention, because of a Codegear warning:
{{{
Warning W8028 ..\..\..\boost/exception/info.hpp 117: Temporary used to
initialize 'x' in function
error_info_container_impl::diagnostic_information(const char *) const
}}}
Each of the two suggested changes would fix the warning.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4337> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC