karolherbst / Gamekeeper-Framework

Library for hooking up game stores and merging them into one single library
GNU Lesser General Public License v2.1
2 stars 0 forks source link

some minor Cleanups and improvements #148

Closed karolherbst closed 9 years ago

Jookia commented 9 years ago

Looks good. I thought move semantics were implicit in some cases?

karolherbst commented 9 years ago

They are, but this is usually in more safier spaces:

safe to assume move:

void func()
{
  std::string str(std::string("hiho")); //implicit move, because temporary string object gets destroyed immediatly => rvalue reference, 
}

not safe to assume move:

void func(std::string str)
{
  std::string str2(str); // no move, because str might be used later on
}

Move only applies on rvalue, not lvalues.

karolherbst commented 9 years ago

The new rule in c++11 is basically: if you copy a reference, then make the copy in the function header, because there you can move optimize. If you use references instead, move optimizations aren't possible at all.

This should be checked in different places I suppose anyway.