Naming a typedef for a boost::shared_ptr<const Foo>
- by Blair Zajac
Silly question, but say you have class Foo:
class Foo
{
public:
typedef boost::shared_ptr<Foo> RcPtr;
void non_const_method() {}
void const_method() const {}
};
Having a const Foo::RcPtr doesn't prevent non-const methods from being invoked on the class, the following will compile:
#include <boost/shared_ptr.hpp>
int main()
{
const Foo::RcPtr const_foo_ptr(new Foo);
const_foo_ptr->non_const_method();
const_foo_ptr->const_method();
return 0;
}
But naming a typedef ConstRcPtr implies, to me, that the typedef would be
typedef const boost::shared_ptr<Foo> ConstRcPtr;
which is not what I'm interested in. An odder name, but maybe more accurate, is RcPtrConst:
typedef boost::shared_ptr<const Foo> RcPtrConst;
However, Googling for RcPtrConst gets zero hits, so people don't use this as a typedef name :)
Does anyone have any other suggestions?