All the smart pointers (for example, boost::scoped_ptr, boost::optional, std::auto_ptr and others) make assertion in order to check whether internal pointer is initialized. It's ok to dereference it some not big number of times, but what if the number of times is really big (counts million, billion times)?
For example, there's a class:
class A
{
public:
A( std::auto_ptr< B > _someObject )
: m_object( _someObject ) {}
B const& getMember() const
{ return *m_object; }
private:
boost::scoped_ptr< B > m_object;
};
The someObject is always not null and somewhere the getMember() is called a very big number of times. On each call, the assertion inside m_object is being made.
Is it preferable to use raw pointer instead? Of course, this will lead to the destructor creation to delete the raw pointer.
Will the assertion have some noticeable impact in such a case? Or that will still be negligible?