I have a class (let's call it myclass
). One of its private member variables is a std::function
called myfunctor
of return type bool
and that takes two arguments:
bool
myfunction
(const std::string & input, std::string & output)
{
output = input;
}
The constructor of myclass
shall receive a reference to the output std::string
as its only parameter, so that the way to initialize it would be something like this:
myclass::myclass
(std::string & s)
: myfunctor( std::bind(myfunction, std::placeholders::_1, s) )
{
return;
}
I was hoping, however, that there's a way to directly use operator=
from std::string
. But I have still not found it. I've tried with many different combinations without luck:
std::bind( (std::string & (std::string::*) (std::string &)) &(s.operator=), placeholders::_1
and so on, but compiler (GCC 4.8.0) gave me errors like no matches converting to ...
.