Using std::swap in move constructors #777
Unanswered
Swat-SomeBug
asked this question in
Q&A
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 |
1 reply
|
I further noticed that implicitly generates a Cpp1 assignment operator Is there a way to disable this? |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?All reactions