Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: base/move_unittest.cc

Issue 1479473002: base: Use std::move() instead of Pass() for real movable types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: basepass: missing-include Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/metrics/sparse_histogram.cc ('k') | base/power_monitor/power_monitor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/move.h" 5 #include "base/move.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace { 9 namespace {
10 10
11 class MoveOnly { 11 class MoveOnly {
12 MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(MoveOnly) 12 MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(MoveOnly)
13 13
14 public: 14 public:
15 MoveOnly() {} 15 MoveOnly() {}
16 16
17 MoveOnly(MoveOnly&& other) {} 17 MoveOnly(MoveOnly&& other) {}
18 MoveOnly& operator=(MoveOnly&& other) { return *this; } 18 MoveOnly& operator=(MoveOnly&& other) { return *this; }
19 }; 19 };
20 20
21 class Container { 21 class Container {
22 public: 22 public:
23 Container() = default; 23 Container() = default;
24 Container(const Container& other) = default; 24 Container(const Container& other) = default;
25 Container& operator=(const Container& other) = default; 25 Container& operator=(const Container& other) = default;
26 26
27 Container(Container&& other) { value_ = other.value_.Pass(); } 27 Container(Container&& other) { value_ = std::move(other.value_); }
28 28
29 Container& operator=(Container&& other) { 29 Container& operator=(Container&& other) {
30 value_ = other.value_.Pass(); 30 value_ = other.value_.Pass();
31 return *this; 31 return *this;
32 } 32 }
33 33
34 private: 34 private:
35 MoveOnly value_; 35 MoveOnly value_;
36 }; 36 };
37 37
38 Container GetContainerRvalue() { 38 Container GetContainerRvalue() {
39 Container x; 39 Container x;
40 return x; 40 return x;
41 } 41 }
42 42
43 TEST(MoveTest, CopyableContainerCanBeMoved) { 43 TEST(MoveTest, CopyableContainerCanBeMoved) {
44 // Container should be move-constructible and move-assignable. 44 // Container should be move-constructible and move-assignable.
45 Container y = GetContainerRvalue(); 45 Container y = GetContainerRvalue();
46 y = GetContainerRvalue(); 46 y = GetContainerRvalue();
47 } 47 }
48 48
49 } // namespace 49 } // namespace
OLDNEW
« no previous file with comments | « base/metrics/sparse_histogram.cc ('k') | base/power_monitor/power_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698