[C++] Knowing when non-const base member functions are called
From: Pocaterra (olivertwist_at_dickens.co.uk)
Date: 10/22/04
- Next message: Mark P: "Re: Tree"
- Previous message: Mike Wahler: "Re: A loop with C struct"
- Next in thread: B. v Ingen Schenau: "Re: [C++] Knowing when non-const base member functions are called"
- Reply: B. v Ingen Schenau: "Re: [C++] Knowing when non-const base member functions are called"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 22 Oct 2004 15:57:59 -0600
Hi:
Suppose I have something like the following:
class Derived : public Base
{
mutable std::auto_ptr<SomeType> m_cachedValue;
virtual void createCachedValue() { ... }
virtual const SomeType& cachedValue() const
{
if( !m_cachedValue.get()
createCachedValue();
return *m_cachedValue;
}
};
I would like to be able to determine when non-const member functions of
Base are called, so that I can delete the cached value that depends on
the data in Base. Is there anyway I can do this?
I've tried making Derived have private inheritance from Base, and then
having 'Base&' and 'const Base&' cast operators, but this doesn't work.
Thanks,
Cameron
- Next message: Mark P: "Re: Tree"
- Previous message: Mike Wahler: "Re: A loop with C struct"
- Next in thread: B. v Ingen Schenau: "Re: [C++] Knowing when non-const base member functions are called"
- Reply: B. v Ingen Schenau: "Re: [C++] Knowing when non-const base member functions are called"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]