vendredi 21 août 2015

Is it safe to call non-const member functions for rvalue objects?

While reading about multithreading in C++11, I noticed that some tutorials do this:

std::thread(print_message, "Hello").detach();

// instead of...

std::thread t(print_message, "Hello");
t.detach();

My questions are:

  1. In general, is it safe to call non-const member functions for temporary (rvalue) objects?
  2. In particular, is it safe to do so for a C++11 std::thread?

Aucun commentaire:

Enregistrer un commentaire