summaryrefslogtreecommitdiffstats
path: root/base/win
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-15 20:36:05 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-15 20:36:05 +0000
commite95d6ed72b41e370140f3103de8b1a3b1eefbfec (patch)
tree49cfef0fc09463dbfc13379cb5b277a07607dadd /base/win
parente1ef4c65ae2a2e75ddfc604f827e77480c36c7fb (diff)
downloadchromium_src-e95d6ed72b41e370140f3103de8b1a3b1eefbfec.zip
chromium_src-e95d6ed72b41e370140f3103de8b1a3b1eefbfec.tar.gz
chromium_src-e95d6ed72b41e370140f3103de8b1a3b1eefbfec.tar.bz2
Fix move.h's to use a concrete RValue carrier object rather than hacking a RValue&.
For move semantics, we need to create a private "RValue" type that is used to create move constructors and move operators. Previously, we emulated Boost's idea of making the RValue type a subclass of the move-only type that doesn't add any new member fields. We then just reinterpret_cast "this" into a RValue& depending on the fact that RValue is just a type pun for the move-only type. This ends up being undefined behavior though (C++98 5.2.10.7). This change makes use a concrete RValue class that contains a pointer to the move-only type. With -O2 on clang version 3.2 (trunk 163674), this yields identical assembly code to the previous implementation. With -O0, we generate 2 more instructions to allocate and initialize the temporary RValue struct's object field when calling Pass(). This should be acceptable. The snowman says so ☃. BUG=155436 Review URL: https://chromiumcodereview.appspot.com/11078014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161945 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/win')
-rw-r--r--base/win/scoped_handle.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/base/win/scoped_handle.h b/base/win/scoped_handle.h
index 62734b6..b5d9b5c 100644
--- a/base/win/scoped_handle.h
+++ b/base/win/scoped_handle.h
@@ -49,8 +49,8 @@ class GenericScopedHandle {
}
// Move constructor for C++03 move emulation of this type.
- GenericScopedHandle(RValue& other) : handle_(Traits::NullHandle()) {
- Set(other.Take());
+ GenericScopedHandle(RValue other) : handle_(Traits::NullHandle()) {
+ Set(other.object->Take());
}
~GenericScopedHandle() {
@@ -62,9 +62,9 @@ class GenericScopedHandle {
}
// Move operator= for C++03 move emulation of this type.
- GenericScopedHandle& operator=(RValue& other) {
- if (this != &other) {
- Set(other.Take());
+ GenericScopedHandle& operator=(RValue other) {
+ if (this != other.object) {
+ Set(other.object->Take());
}
return *this;
}