std::bind(&Class::func, obj, std::placeholders::_1)
[obj] (const SomeType& v) { return obj->func(v); }
tr1
. int foo(int& bar)
, то нельзя будет написать foo(3)
, или foo(sin(5))
. he rule of thumb is never rely on a const-reference existing beyond the lifetime of the function that receives it as a parameter
struct S
{
S(const int& v):v(v){} //this is bad
const int& v;
}
int main()
{
S s(6); //because this can happen
std::cout << s.v;
}
class S
{
public:
std::string text;
};