compilation error with progress_handler

Aug 19, 2015 at 10:35 AM
I have a compilation problem with a progress_handler (in a method of COCom) :

std::function< void(message_direction::direction, utility::size64_t)> f = &COCom::progress;

//or
//progress_handler f = &COCom::progress;

requete.set_progress_handler(f);


I get this error:

1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\functional(506): error C2664: 'void std::_Func_class<_Ret,web::http::message_direction::direction,utility::size64_t>::_Set(std::_Func_base<_Ret,web::http::message_direction::direction,utility::size64_t> *)' : cannot convert argument 1 from '_Myimpl *' to 'std::_Func_base<_Ret,web::http::message_direction::direction,utility::size64_t> *'
1> with
1> [
1> _Ret=void
1> ]
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

I use visual studio 2013 Pro update5.
Aug 24, 2015 at 10:33 AM
it is solved like this :

progress_handler f = [this](message_direction::direction dir, utility::size64_t size) {
                this->progress(dir, size); };
Marked as answer by stephane_l2 on 8/24/2015 at 2:33 AM