Hello!
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);
Hello!
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);
The problem is that std::fill
is a template function. Template functions don't really exist, so to say, until they're instantiated. You can't take the address of std::fill
because 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::fill
function 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 the std::fill
template you want to use.
std::vector<int> x(10);
boost::bind(std::fill<std::vector<int>::iterator, int>, x.begin(), x.end(), 1);