I want to write a function that would use libcurl to would a file and then store into into a container. I'd like to use iterators for this to abstract away the type of the container. The function would look like this:
template <typename OutIt>
bool download_to_container(const std::string& link, OutIt out)
{
//set the write callback
//perform the action
//return whatever
}
The write callback is a function of signature size_t(char*, size_t, size_t, void *userdata)
where userdata
is a pointer I can set that libcurl will pass into the write callback for me.
This userdata
will be a pointer to the output iterator the user has passed into download_to_container
. Now, once the callback is called, I'll have to cast that void*
into an OutIt*
. How can I do this if I don't know the type of the iterator? This is my first time encountering this problem so please go easy on me. :-)
I'm using Microsoft Visual C++ Compiler Nov 2012 CTP (v120_CTP_Nov2012)
.