c++ - Getting value from a pair fails with: TYPENAME does not provide a call operator -
here want do. want store de data http response, headers , data. figured easy way store response , data pair. data fetched lru-cache. lru cache takes key(string) , pair. httpresponse in form of poco c++ httpresponse object. cant string second argument of pair!
this->clientcache = new lrupersistentcache<string, pair<httpresponse, string > >(3,cachepath); pair<httpresponse,string> tmp = (*this->clientcache->get(headkey));// pair cout << ((string*)tmp.second()).c_str(); //should second object of pair! // gives: type std::basic_string<char> not provide call operator.
writing below gives same error:
cout << (*this->clientcache->get(headkey)).second().c_str();
what doing wrong here?
cout << ((string*)tmp.second()).c_str(); ^^
you casting string*
. should string
(or nothing @ all) because second
of pair<httpresponse,string>
string
.
and second member not member function should tmp.second
cout << tmp.second.c_str();