Opened 12 years ago
Closed 12 years ago
#4337 closed Bugs (fixed)
info.hpp: unnecessary (?) temporary shared_ptr<error_info_base const>
Reported by: | niels_dekker | Owned by: | Emil Dotchevski |
---|---|---|---|
Milestone: | Boost 1.43.0 | Component: | exception |
Version: | Boost 1.44.0 | Severity: | Optimization |
Keywords: | Cc: |
Description
It seems to me that the creation of a temporary shared_ptr<error_info_base const> object at 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.
Note:
See TracTickets
for help on using tickets.
Thanks, fixed in trunk revision 62892.