c++ - If you include const in a function, is & redundant? -
will 2 function specifications below compile same thing? can't see copy needed if you're using const. if aren't same, why?
void(const int y); void(const int& y);
not same. if argument changes after it's passed (e.g. because it's changed thread), first version unaffected because has copy. in second variant, function called may not change argument itself, affected changes y
. threads, might mean requires mutex lock.
Comments
Post a Comment