boost::bind использование в классе
От: st0nx  
Дата: 14.02.11 07:42
Оценка:
struct stringdouble
{
    std::string a;
    std::string b;
};
class HttpSendRecv_boost
{

public:
//...
private:
    std::string rStr;
    vector <stringdouble> cookie; 
    void GET_COOKIE();
    bool findvector(stringdouble ch,stringdouble s);
};


bool HttpSendRecv_boost::findvector(stringdouble ch,stringdouble s)
{
if(ch.a == s.a) 
     return true;
  return false;
};

void HttpSendRecv_boost::GET_COOKIE()
{
    stringdouble buf;
    boost::regex xRegEx("Set-Cookie: (.+?)=(.+?);");
    boost::smatch xResults;
    std::string::const_iterator xItStart = rStr.begin();
    std::string::const_iterator xItEnd = rStr.end();
    while( boost::regex_search(xItStart, xItEnd, xResults, xRegEx) )
    {
        buf.a = boost::lexical_cast<std::string>(xResults[1]);
        buf.b = boost::lexical_cast<std::string>(xResults[2]);
        if(std::find_if(cookie.begin(),cookie.end(),(boost::bind(&HttpSendRecv_boost::findvector,_1,_2,_3,buf))) == cookie.end())
        {
            cookie.push_back(buf);
        }
      xItStart = xResults[1].second;
    }
};


Я не очень понимаю как использовать внутри класса boost::bind (при написании пользовался статьей: http://www.rsdn.ru/article/cpp/boost.bind.xml
Автор(ы): Bjorn Karlsson
Дата: 24.02.2006
Рассматриваются все типовые случаи применения bind — связывание свободных функций, функций-членов класов, переменных-членов, виртуальных функций, а также функциональная композиция. На простом примере поясняется идея, лежащая в основе реализации bind.
).

Ошибки компиляции:

1>E:\Program Files\Microsoft Visual Studio 9.0\VC\include\boost/bind/bind.hpp(69) : error C2825: 'F': must be a class or namespace when followed by '::'
1> E:\Program Files\Microsoft Visual Studio 9.0\VC\include\boost/bind/bind_template.hpp(15) : see reference to class template instantiation 'boost::_bi::result_traits<R,F>' being compiled
1> with
1> [
1> R=boost::_bi::unspecified,
1> F=bool (__thiscall HttpSendRecv_boost::* )(stringdouble,stringdouble)
1> ]
1> .\Class_HTTP.cpp(152) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled
1> with
1> [
1> R=boost::_bi::unspecified,
1> F=bool (__thiscall HttpSendRecv_boost::* )(stringdouble,stringdouble),
1> L=boost::_bi::list4<boost::arg<1>,boost::arg<2>,boost::arg<3>,boost::_bi::value<stringdouble>>
1> ]
1>E:\Program Files\Microsoft Visual Studio 9.0\VC\include\boost/bind/bind.hpp(69) : error C2039: 'result_type' : is not a member of '`global namespace''
1>E:\Program Files\Microsoft Visual Studio 9.0\VC\include\boost/bind/bind.hpp(69) : error C2146: syntax error : missing ';' before identifier 'type'
1>E:\Program Files\Microsoft Visual Studio 9.0\VC\include\boost/bind/bind.hpp(69) : error C2208: 'boost::_bi::type' : no members defined using this type
1>E:\Program Files\Microsoft Visual Studio 9.0\VC\include\boost/bind/bind.hpp(69) : fatal error C1903: unable to recover from previous error(s); stopping compilation

 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.