There are other cases where this might not possible. Here is an example from Dietmar Kuhl:
std::auto_ptr<T> factory();
void foo()
{
whatever_ptr ptr = factory();
// ...
}
You can't make the return value of factory() const, because assignments of an auto_ptr change the auto_ptr.
References:
Exceptional C++
Dietmar Kuhl, Personal Communication

No comments:
Post a Comment