
I have a question regarding shared_ptr implementation: currently shared_ptr is implementated so, that it contains: T * px; // contained pointer detail::shared_count pn; // reference counter I am interested to know philosophical thoughts why this kind of decision was made to implement the shared_ptr class this way? I assumed to save space which is consumed by such a pointer one could move T pointer (T*) to shared_count class. All shared_ptr classes would contain only one instance or (may be better pointer to counter): detail::shared_count* pn; // reference counter and the approach to retrieve pointer would be: pn->px //since px would be moved to pn This would reduce the size of shared_ptr<T> to sizeof(detail::shared_count*) which is at least by sizeof(detail::shared_count) smaller of may be more if alignment has to used. Are there any arguments which prevent shared_ptr from such implementation scenario? With Kind Regards, Ovanes Markarian