Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Default move constructor/assignment

Reply
Thread Tools

Default move constructor/assignment

 
 
woodbrian77@gmail.com
Guest
Posts: n/a
 
      04-08-2012
On Saturday, April 7, 2012 5:59:28 PM UTC-5, (E-Mail Removed) wrote:
> On Saturday, April 7, 2012 12:34:01 PM UTC-5, Howard Hinnant wrote:
> >
> > I agree too. However it is good to be aware of the cases that do
> > break, so you can learn to recognize them, and learn how to fix them.
> >

>
> Right.
>
> > The most convincing case I've seen to date is this one:
> >

>
> Thanks for the detailed explanation.
>
>
> > Image(Image&& img)
> > : m_data(std::move(img.m_data)),

>
> I recall something Anthony Williams wrote about the
> members of an rvalue reference being rvalue references
> and not needing to use std::move there. Perhaps you
> use it as a reminder of what is happening and not
> because it's really needed?


I read the thread you linked to in the moderated group
now and the std::move is needed. It's been a while since
I read what Anthony wrote so don't know if I'm remembering
things wrong or he was mistaken.

 
Reply With Quote
 
 
 
 
SG
Guest
Posts: n/a
 
      04-10-2012
On 8 Apr., 00:59, woodbria... wrote:
> On Saturday, April 7, 2012 12:34:01 PM UTC-5, Howard Hinnant wrote:
>
> > The most convincing case I've seen to date is this one:

>
> Thanks for the detailed explanation.
>
> > * * Image(Image&& img)
> > * * * * : m_data(std::move(img.m_data)),

>
> I recall something Anthony Williams wrote about the
> members of an rvalue reference being rvalue references
> and not needing to use std::move there. *Perhaps you
> use it as a reminder of what is happening and not
> because it's really needed?


References have no members. And `img` is an lvalue expression. So an
explicit std::move is required to select the move constructor. But
you can also write

std::move(img).m_data

because member access on an rvalue expression yields an rvalue
expression.

Cheers!
SG
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing move constructors and move assignment Andrew Tomazos C++ 2 12-12-2011 01:45 PM
I am trying to move spaces to a weblistbox and when I move them... Eduardo78 ASP .Net Web Controls 0 11-03-2005 06:06 PM
Default Domain Policy vs Default Domain Controller Policy Tyler Cobb MCSE 6 10-19-2005 09:36 PM
Default Mozilla isn't default! Help! M. FERRANTE Firefox 1 07-27-2005 09:07 AM
automatic default route propagation into RIP: default metric Ben Low Cisco 2 12-28-2003 03:57 AM



Advertisments