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

Side by Side Diff: base/move.h

Issue 1501793003: Rename MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/memory/scoped_ptr.h ('k') | base/scoped_generic.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef BASE_MOVE_H_ 5 #ifndef BASE_MOVE_H_
6 #define BASE_MOVE_H_ 6 #define BASE_MOVE_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 12 matching lines...) Expand all
23 // * Passed as a function argument 23 // * Passed as a function argument
24 // * Used as the right-hand side of an assignment 24 // * Used as the right-hand side of an assignment
25 // * Returned from a function 25 // * Returned from a function
26 // 26 //
27 // Each class will still need to define their own move constructor and move 27 // Each class will still need to define their own move constructor and move
28 // operator= to make this useful. Here's an example of the macro, the move 28 // operator= to make this useful. Here's an example of the macro, the move
29 // constructor, and the move operator= from a hypothetical scoped_ptr class: 29 // constructor, and the move operator= from a hypothetical scoped_ptr class:
30 // 30 //
31 // template <typename T> 31 // template <typename T>
32 // class scoped_ptr { 32 // class scoped_ptr {
33 // MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(type); 33 // DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(type);
34 // public: 34 // public:
35 // scoped_ptr(scoped_ptr&& other) : ptr_(other.release()) { } 35 // scoped_ptr(scoped_ptr&& other) : ptr_(other.release()) { }
36 // scoped_ptr& operator=(scoped_ptr&& other) { 36 // scoped_ptr& operator=(scoped_ptr&& other) {
37 // reset(other.release()); 37 // reset(other.release());
38 // return *this; 38 // return *this;
39 // } 39 // }
40 // }; 40 // };
41 // 41 //
42 // 42 //
43 // WHY HAVE typedef void MoveOnlyTypeForCPP03 43 // WHY HAVE typedef void MoveOnlyTypeForCPP03
44 // 44 //
45 // Callback<>/Bind() needs to understand movable-but-not-copyable semantics 45 // Callback<>/Bind() needs to understand movable-but-not-copyable semantics
46 // to call .Pass() appropriately when it is expected to transfer the value. 46 // to call .Pass() appropriately when it is expected to transfer the value.
47 // The cryptic typedef MoveOnlyTypeForCPP03 is added to make this check 47 // The cryptic typedef MoveOnlyTypeForCPP03 is added to make this check
48 // easy and automatic in helper templates for Callback<>/Bind(). 48 // easy and automatic in helper templates for Callback<>/Bind().
49 // See IsMoveOnlyType template and its usage in base/callback_internal.h 49 // See IsMoveOnlyType template and its usage in base/callback_internal.h
50 // for more details. 50 // for more details.
51 51
52 #define MOVE_ONLY_TYPE_FOR_CPP_03(type) \ 52 #define MOVE_ONLY_TYPE_FOR_CPP_03(type) \
53 MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(type) 53 DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(type)
54 54
55 #define MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(type) \ 55 #define DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(type) \
Nico 2015/12/04 21:58:05 What do you think is the long term plan for this?
danakj 2015/12/04 22:01:47 We'll still need the typedef whitelist once Pass()
dcheng 2015/12/04 22:14:00 I've been thinking: is there a value to forcing th
56 private: \ 56 private: \
57 type(const type&) = delete; \ 57 type(const type&) = delete; \
58 void operator=(const type&) = delete; \ 58 void operator=(const type&) = delete; \
59 \ 59 \
60 public: \ 60 public: \
61 type&& Pass() WARN_UNUSED_RESULT { return std::move(*this); } \ 61 type&& Pass() WARN_UNUSED_RESULT { return std::move(*this); } \
62 typedef void MoveOnlyTypeForCPP03; \ 62 typedef void MoveOnlyTypeForCPP03; \
63 \ 63 \
64 private: 64 private:
65 65
66 #endif // BASE_MOVE_H_ 66 #endif // BASE_MOVE_H_
OLDNEW
« no previous file with comments | « base/memory/scoped_ptr.h ('k') | base/scoped_generic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698