Recently, I read an article about lazy data structures in C++ (this question is not about lazy, or the particular data structure, though - it is just the motivation).
A lazy stream (list) is implemented as follows:
std::shared_ptr <Susp<Cell<T>>> _lazyCell;
Stream(Stream && stm)
Stream & operator=(Stream && stm)
_lazyCell = std::move(stm._lazyCell);
bool isEmpty() const
T get() const
Stream<T> pop_front() const
I also added a move constructor and a move assignment operator for efficiency.
shared_ptr is used internally to share lazy value cells as part of the private implementation.
However, from the user's point of view, it's an immutable object. Providing a copy constructor and assignment operator would undo this immutability.
He is modelling Haskell's immutable object's behaviour.
If it were thread-safe to do so, it would be reasonable to make this object copyable since in reality it's a handle to an (albeit more complex than usual) shared impl.
However, copyers would need to understand that they were copying a handle to shared state, and not state itself.