Skip to content

Commit f484f72

Browse files
vmpstrCommit bot
authored and
Commit bot
committed
styleguide: Allow std::move for move semantics.
R=danakj@chromium.org, thakis@chromium.org Review URL: https://codereview.chromium.org/1450013002 Cr-Commit-Position: refs/heads/master@{#359949}
1 parent fe8f3f5 commit f484f72

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

base/move.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#ifndef BASE_MOVE_H_
66
#define BASE_MOVE_H_
77

8+
#include <utility>
9+
810
#include "base/compiler_specific.h"
911

1012
// Macro with the boilerplate that makes a type move-only in C++03.
@@ -222,13 +224,13 @@
222224
type(const type&); \
223225
void operator=(const type&); \
224226
public: \
225-
type&& Pass() WARN_UNUSED_RESULT { return static_cast<type&&>(*this); } \
227+
type&& Pass() WARN_UNUSED_RESULT { return std::move(*this); } \
226228
typedef void MoveOnlyTypeForCPP03; \
227229
private:
228230

229231
#define TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(type) \
230232
public: \
231-
type&& Pass() WARN_UNUSED_RESULT { return static_cast<type&&>(*this); } \
233+
type&& Pass() WARN_UNUSED_RESULT { return std::move(*this); } \
232234
private:
233235

234236
#endif // BASE_MOVE_H_

styleguide/c++/c++11.html

+10-9
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,16 @@ <h2 id="whitelist">C++11 Allowed Library Features</h2>
288288
<td><a href="http://en.cppreference.com/w/cpp/utility/tuple/tie">std::tie</a></td>
289289
<td>General use of <code>std::tuple</code>, and <code>std::tie</code> for unpacking or multiple assignments is still not allowed. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/3DZ64dIMRTY/discussion">Discussion thread</a></td>
290290
</tr>
291+
292+
<tr>
293+
<td>Move Semantics</td>
294+
<td><code>std::move()</code></td>
295+
<td>Facilitates efficient move operations</td>
296+
<td><a href="http://en.cppreference.com/w/cpp/utility/move">
297+
<code>std::move</code> reference</a></td>
298+
<td>Note: std::move() is allowed but writing your own move constructors is still only allowed in exceptional cases for now, see 'Rvalue References (and Move Semantics)'. <a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJFdbM'>Discussion thread</a></td>
299+
</tr>
300+
291301
</tbody>
292302
</table>
293303

@@ -808,15 +818,6 @@ <h3 id="blacklist_stdlib">C++11 Standard Library Features To Be Discussed</h3>
808818
<td></td>
809819
</tr>
810820

811-
<tr>
812-
<td>Move Semantics</td>
813-
<td><code>std::move()</code></td>
814-
<td>Facilitates efficient move operations</td>
815-
<td><a href="http://en.cppreference.com/w/cpp/utility/move">
816-
<code>std::move</code> reference</a></td>
817-
<td></td>
818-
</tr>
819-
820821
<tr>
821822
<td>Pointer Traits Class Template</td>
822823
<td><code>std::pointer_traits</code></td>

0 commit comments

Comments
 (0)