Is there any way to make boost::bind work with std::fill?
I tried the following, but it didn’t work:
boost::bind(std::fill, x.begin(), x.end(), 1);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem is that
std::fillis a template function. Template functions don’t really exist, so to say, until they’re instantiated. You can’t take the address ofstd::fillbecause it doesn’t really exist; it’s just a template for similar functions that use different types. If you provide the template parameters, it will refer to a specific instantiation of the template, and everything will be okay.The
std::fillfunction has two template parameters: ForwardIteratorType, which is the type of an iterator to the container, and DataType, which is the type that container holds. You need to provide both, so the compiler knows which instantiation of thestd::filltemplate you want to use.