folly::rvalue_reference_wrapper for store&forward of rvalue references
authorPhilipp Unterbrunner <philippu@fb.com>
Thu, 27 Apr 2017 21:03:31 +0000 (14:03 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 27 Apr 2017 21:06:15 +0000 (14:06 -0700)
commit682dfa7172b2e7ec39e2a29583292f7e2e06b63f
treeb69c279eca6652aa548d8a5a4a295b2a9d1378f1
parent95209f9d06df94908db7dbf5a4067eca11b9da59
folly::rvalue_reference_wrapper for store&forward of rvalue references

Summary:
Class template that wraps a reference to an rvalue. Similar to std::reference_wrapper but with three important differences:
1) folly::rvalue_reference_wrappers can only be moved, not copied;
2) the get() function and the conversion-to-T operator are destructive and not const, they invalidate the wrapper;
3) the constructor-from-T is explicit.
These restrictions are designed to make it harder to accidentally create a a dangling rvalue reference, or to use an rvalue reference multiple times. (Using an rvalue reference typically implies invalidation of the target object, such as move-assignment to another object.)

Reviewed By: yfeldblum

Differential Revision: D4931483

fbshipit-source-id: 68453553bf4656ec41976699669a4491fcab79c9
folly/Functional.h [new file with mode: 0644]
folly/Makefile.am
folly/test/FunctionalTest.cpp [new file with mode: 0644]
folly/test/Makefile.am