From 39ee69117e66c57925ac1a8c994e6ce747438fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sj=C3=B6l=C3=A9n?= Date: Tue, 22 Aug 2023 14:00:40 +0200 Subject: [PATCH 1/4] Move over Rvalue references and move semantics to permitted features --- doc/hotspot-style.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/hotspot-style.md b/doc/hotspot-style.md index 9743c77871fae..08ea1c4279da0 100644 --- a/doc/hotspot-style.md +++ b/doc/hotspot-style.md @@ -1086,6 +1086,9 @@ The following attributes are expressly forbidden: ### Additional Permitted Features +* Rvalue references and move semantics +([n1690](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1690.html)) + * `alignof` ([n2341](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf)) @@ -1210,8 +1213,6 @@ features that have not yet been discussed. * Member initializers and aggregates ([n3653](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3653.html)) -* Rvalue references and move semantics - [ADL]: https://en.cppreference.com/w/cpp/language/adl "Argument Dependent Lookup" From a85b1d18e1734fd35faa2beb9483c9b5fb722228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sj=C3=B6l=C3=A9n?= Date: Tue, 22 Aug 2023 14:10:15 +0200 Subject: [PATCH 2/4] Also update html --- doc/hotspot-style.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/hotspot-style.html b/doc/hotspot-style.html index ced607d71090e..d7d9335f6f310 100644 --- a/doc/hotspot-style.html +++ b/doc/hotspot-style.html @@ -1093,6 +1093,8 @@

Attributes

Additional Permitted Features

From 0d117e81c99dccc591869942602417774e2bdb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sj=C3=B6l=C3=A9n?= Date: Tue, 24 Oct 2023 12:35:36 +0200 Subject: [PATCH 3/4] Expand on the feature --- doc/hotspot-style.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/hotspot-style.md b/doc/hotspot-style.md index 08ea1c4279da0..b2bd5add8b94d 100644 --- a/doc/hotspot-style.md +++ b/doc/hotspot-style.md @@ -1088,6 +1088,13 @@ The following attributes are expressly forbidden: * Rvalue references and move semantics ([n1690](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1690.html)) +Rvalue references and move semantics is an advanced C++ concept and should be +treated as such. In HotSpot we prefer copy construction when possible. +However, we do recognize that there are cases where move semantics permit significant +ergonomic and performance advantages to the developer. +For example, if you have a data structure T which is non-copyable but needs to +be stored in a resizable container, then defining a move constructor may be preferable +to changing the contained element type from T to T\*. * `alignof` ([n2341](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf)) From 2cba5f23ea221dc0fe6cee6d6c2ea64aef847adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sj=C3=B6l=C3=A9n?= Date: Tue, 24 Oct 2023 12:36:46 +0200 Subject: [PATCH 4/4] Add a (admittedly clunky) single asterisk --- doc/hotspot-style.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/hotspot-style.md b/doc/hotspot-style.md index b2bd5add8b94d..83ac2b7bfc6a8 100644 --- a/doc/hotspot-style.md +++ b/doc/hotspot-style.md @@ -1088,6 +1088,7 @@ The following attributes are expressly forbidden: * Rvalue references and move semantics ([n1690](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1690.html)) +* Use `std::move` when moving an object. Rvalue references and move semantics is an advanced C++ concept and should be treated as such. In HotSpot we prefer copy construction when possible. However, we do recognize that there are cases where move semantics permit significant