Subject: [Boost-bugs] [Boost C++ Libraries] #2144: boost::thread constructor wants to make copies of the argument
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-07-24 13:54:54
#2144: boost::thread constructor wants to make copies of the argument
-----------------------------------+----------------------------------------
Reporter: mmikucionis_at_[hidden] | Owner: anthonyw
Type: Bugs | Status: new
Milestone: Boost 1.36.0 | Component: thread
Version: Boost 1.35.0 | Severity: Optimization
Keywords: |
-----------------------------------+----------------------------------------
Hi,
I noticed that boost::thread constructor makes a copy of its argument.
Suppose I have a big structure that I use as thread context and I don't
want redundant copies on stack or anywhere else.
For example:
struct foo
{
void operator()()
{
// zzz
}
private:
foo(foo&); // no copying, please
};
boost::thread(foo()); // this fails due to private copy constructor
I bumped into this problem when I included boost::thread itself into the
structure (forbids copying too ;).
Thus I wonder if the argument could be replaced by a reference to an
argument which would not insist on copying things.
As a workaround I do the following now:
void bar(foo *ptr) { (*ptr)(); }
boost::thread(boost::bind(bar, new foo));
I looked at repository on the web and I could not find class thread
anymore (moved somewhere else since 1.35?), so maybe it's already fixed...
Thanks for great library!
-- Ticket URL: <http://svn.boost.org/trac/boost/ticket/2144> 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:49:58 UTC