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.
-
I wanted to write a
resource
handle 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
swap
this.r_
andthat.r_
asstd::swap
expects lvalues (understandably).However, cppfront,
move
sthat
intostd::swap
.Using
_ = that;
doesn't work here, as I get an error from cppfront regarding a double move.Is there some guidance in writing
resource
handles incpp2
syntax?Beta Was this translation helpful? Give feedback.
All reactions