Subject: Re: [boost] [smart_ptr] No more shared_ptr<T>::value_type?
From: Peter Dimov (lists_at_[hidden])
Date: 2013-04-16 13:45:49
Andrew Hundt wrote:
> I updated from boost 1.52 to 1.53 and it appears that the typedefs have
> been removed, I couldn't find any mention of it in the release notes, and
> I searched the list for shared_ptr value_type and saw no mention of the
> change there. Was this a deliberate change?
> This breaks a *lot* of code for me, and will make more difficult for me to
> convince my team to continue to use boost or upgrade in the future because
> they are very apprehensive of breaking changes. I understand if it has
> been removed to be C++11 compliant but I expected some warning before
> breaking changes like this.
As Nathan already pointed out, value_type has never been a documented part
of shared_ptr's interface. It should never have been added in the first
place. Containers, allocators and iterators have a value_type, and
shared_ptr is none of those. In addition, even if we squint and view it as
iterator-like, value_type is and has always been wrong - the value_type of a
pointer to a const T must be T and not const T.
You probably want element_type, although it depends on the specific case.
shared_ptr<T>::element_type was always T before 1.53, but in 1.53
shared_ptr<int>::element_type is int and not int. This is not likely to
be a problem in existing code, though.