Does boost::bind() copy parameters by reference or by value?
问题 Why does valgrind's DRD tool complaines "Conflicting load by thread ... at size 4": about such code: void SomeFunction(const int& value) { boost::bind(..., value); /* <-- complaines on this line with last backtrace function "new(int)" */ } Does boost::bind() stores values by reference or value? 回答1: By value. 1 But you can make it copy by ref instead: void SomeFunction(const int& value) { boost::bind(..., boost::ref(value)); boost::bind(..., boost::cref(value)); // by const ref } 1 http://www