From: Alex Landau Date: Tue, 29 Oct 2013 21:06:18 +0000 (-0700) Subject: Fix passing MoveWrapper into lambdas X-Git-Tag: v0.22.0~806 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=e14cd5e1ff7cea2f607d2b1741a26942745965af;p=folly.git Fix passing MoveWrapper into lambdas Summary: GCC can't compile code that passes a MoveWrapper into a lambda in some cases. For example if the capture list has [someConstObject, myMoveWrapper], gcc 4.7 fails. This specific case works with gcc 4.8, but other cases (e.g. [this, myMoveWrapper]) still fail. This diff is a hack that makes code like that compile. It can be removed, along with MoveWrapper itself once we move to C++14 with its extended lambda syntax. Test Plan: fbmake Reviewed By: hans@fb.com FB internal diff: D1032585 --- diff --git a/folly/MoveWrapper.h b/folly/MoveWrapper.h index bbdca228..481af489 100644 --- a/folly/MoveWrapper.h +++ b/folly/MoveWrapper.h @@ -43,7 +43,7 @@ class MoveWrapper { MoveWrapper(T&& t) : value(std::move(t)) {} /// copy is move - MoveWrapper(MoveWrapper& other) : value(std::move(other.value)) {} + MoveWrapper(const MoveWrapper& other) : value(std::move(other.value)) {} /// move is also move MoveWrapper(MoveWrapper&& other) : value(std::move(other.value)) {} @@ -60,7 +60,7 @@ class MoveWrapper { MoveWrapper& operator=(MoveWrapper&&) = delete; private: - T value; + mutable T value; }; template