Using std::swap in move constructors #777
Replies: 2 comments 3 replies
-
Same guidance as in Cpp1: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#S-resource. I honestly don't remember the semantics of |
Beta Was this translation helpful? Give feedback.
-
|
I further noticed that implicitly generates a Cpp1 assignment operator Is there a way to disable this? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I wanted to write a
resourcehandle type incpp2, to explore the syntax. I came up with this very crude code:While the code above has several problems, I'm currently unable to
swapthis.r_andthat.r_asstd::swapexpects lvalues (understandably).However, cppfront,
movesthatintostd::swap.Using
_ = that;doesn't work here, as I get an error from cppfront regarding a double move.Is there some guidance in writing
resourcehandles incpp2syntax?Beta Was this translation helpful? Give feedback.
All reactions