This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: std::packaged_task trunk problem
On 7 November 2011 09:26, Lars Gullik Bjønnes wrote:
>
> This is the wrapper I ended up with. I had to remove the throw, it
> triggered all the time.
What if you give PretendToBeCopyable a noexcept destructor?
That should ensure the container will move it rather than copy it,
whenever possible.
> template<typename Moveable>
> struct PretendToBeCopyable
> {
> ? ? ? ?explicit PretendToBeCopyable(Moveable&& m) : m(std::move(m)) {}
> ? ? ? ?PretendToBeCopyable(PretendToBeCopyable&&) = default;
> ? ? ? ?PretendToBeCopyable(PretendToBeCopyable& p)
> ? ? ? ? ? ? ? ?: m(std::move(p.m)) {}
> ? ? ? ?void operator()() { m(); }
~PretendToBeCopyable() noexcept = default;
> private:
> ? ? ? ?Moveable m;
> };
>
> }