Re: [cgi-devel] [Cgi-devel] request const access
Status: Beta
Brought to you by:
drrngrvy
From: Darren G. <lis...@go...> - 2010-07-27 00:34:45
|
Hi Richard, On 6 July 2010 12:13, Richard Forrest <ri...@th...> wrote: > > Thanks for responding so quickly to my bug report yesterday. > Sorry about the slowness of this one! Apparently it slipped through my inbox. > Today I have a const correctness problem. > > I have a 'request' object that has been passed by const reference and > would like to query the contents of its get, session etc. > > 1. data_map_proxy::count(const key_type&) is not a const member > function. Is there any reason for that? I tried changing it to const > without any obvious problems. > No reason. I've changed this to const locally. > 2. I can use pick() to access 'get' parameters but it does not seem to > work for 'session' parameters. Is there any way to access session > parameters in a const context? > The session data doesn't have pick(), but should be accessible in a const context. Are you able to post a short test case please? I've wondered about this inconsistency before, but decided against "fleshing out" the session to have the same members as the other request data. The basic_session<> class template is as slim as possible since the idea is that library users can customise it. The class itself is little more than: template<typename T> class basic_session : public T, noncopyable { // getter / setter for the session id. string const& id() const; void id(string const&); // check / set if the session is loaded. bool loaded() const; void loaded(bool); }; The only reason count(), et al. exist is that T defaults to std::map<string,string>. One option that is possible is to default T to a wrapper over std::map<> that adds the pick(), etc. members. Thoughts? Cheers, Darren |