|
|
Choosing A Webhost: |
ObjectPtrT::operator-> const problem: msg#00005apache.logging.log4cxx.user
I've noticed the const version of this method is returning a pointer to const. The reason this is a problem is that it makes it impossible to log from const methods when LoggerPtr is a member variable: class C { public: C() : logger(log4cxx::Logger::getLogger("my logger")) { } void constMethod() const { // Error: can't do this because the const version of ObjectPtrT::operator->() // must be used, and it returns a pointer to const T. LOG4CXX_DEBUG(logger, "debug message"); } private: log4cxx::LoggerPtr logger; }; In both versions of operator->, the ObjectPtrT itself cannot be modified, so it's not clear why there is a need for a non-const version, or for a version that returns a pointer to const. It seems that in this case, the notion of pointer constness is being conflated with the notion of pointee constness. Surely the above example is not such an unreasonable a thing to expect to be able to do? :) BTW, I wasn't sure whether this was more appropriate for the user list or the dev list (I'm subscribed to both). Scott McCaskill
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Compiling SVN revision 592828, Renato Fernandes Cantão |
|---|---|
| Next by Date: | Re: Compiling SVN revision 592828, Curt Arnold |
| Previous by Thread: | Compiling SVN revision 592828, Renato Fernandes Cantão |
| Next by Thread: | Re: ObjectPtrT::operator-> const problem, Curt Arnold |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |