Jump to content
  • Advertisement
Sign in to follow this  

Confused about move semantics

This topic is 2357 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This function was written by a code generator:

template <typename R>
Receive (::cmw::ReceiveBufferTCPCompressed<R>& buf
, ::std::vector<cmw::File>& az1
uint32_t headCount[1];
az1.reserve(az1.size() + headCount[0]);
for (; headCount[0] > 0; --headCount[0]) {
cmw::File rep2(buf);

My question has to do with the code in the loop. File.hh is here and File.cc is here. (All of the code in question can be downloaded here.)
If I change the last line in the loop to:

the size of the executable is reduced by 492 bytes. I thought that since File has a user defined copy constructor and destructor, the compiler wouldn't generate a move constructor for the class. I figured the compiler would ignore the std::move call and use the copy constructor and the two versions would produce the same size executables. What am I missing? Thanks.

Edit: The compiler is g++ 4.8 released a few days ago -- April 29th.
(I'm also wondering how to build just g++ when I download a gcc snapshot. It builds a bunch of Fortran and Java stuff that I'm not interested in.) Edited by wood_brian

Share this post

Link to post
Share on other sites
Someone on another newsgroup gave what seems to be a helpful explanation:


Share this post

Link to post
Share on other sites
You might want to compare the linker map files from the two versions. In my experience that usually tells you where size differences come from, as long as you can decipher the symbol names.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!