Opened 7 years ago
Closed 7 years ago
#11672 closed Bugs (fixed)
Thread: Should use unique_ptr, not auto_ptr
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.60.0 | Component: | thread |
Version: | Boost 1.59.0 | Severity: | Problem |
Keywords: | auto_ptr | Cc: |
Description
Boost.Thread has two occurrences of auto_ptr
, which is deprecated since C++11:
$ grep -rn 'auto_ptr' include/boost/thread/detail/thread_group.hpp:78: std::auto_ptr<thread> new_thread(new thread(threadfunc)); src/win32/thread.cpp:156: std::auto_ptr< ThreadProxyData> data(reinterpret_cast< ThreadProxyData*>(args));
This causes a warning when compiling with gcc-5.2, and soon other compilers as they become compliant with the clause "std::auto_ptr is deprecated".
I can see the following ways to resolve the warning:
- Literally silence the warning, like in #11622. I view this as a very bad idea.
- Use
std::unique_ptr
if using C++11 or newer. I view this as a bad idea. - Use
boost::movelib::unique_ptr
. I view this as a good idea.
I checked both occurrences of auto_ptr
by hand, and found that in both cases, std::unique_ptr can be used just as well! (In both cases, auto_ptr
is only used to guarantee a call to delete
in case anything throws.)
Change History (4)
comment:1 by , 7 years ago
comment:3 by , 7 years ago
Milestone: | To Be Determined → Boost 1.60.0 |
---|
comment:4 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Created fix and submitted as PR: https://github.com/boostorg/thread/pull/66