[smart_ptr] No more shared_ptr<T>::value_type?
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. boost::thread and boost::filesystem are good examples of changes that were made with solid advance notice. This caught me completely by surprise, did I miss something obvious? Could someone point me to the recommended alternative as well? 1.52 has typedef T value_type: http://www.boost.org/doc/libs/1_52_0/boost/smart_ptr/shared_ptr.hpp 1.53 does not: http://www.boost.org/doc/libs/1_53_0/boost/smart_ptr/shared_ptr.hpp Thanks for your help! Cheers! Andrew Hundt
On Tue, Apr 16, 2013 at 10:21 AM, Andrew Hundt
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. boost::thread and boost::filesystem are good examples of changes that were made with solid advance notice. This caught me completely by surprise, did I miss something obvious?
Could someone point me to the recommended alternative as well?
Even in 1.52 & previous, I don't think value_type was documented -- element_type was: typedef T element_type; Provides the type of the template parameter T. The documented interface didn't change, for what that's worth. HTH, Nate
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
On Tue, Apr 16, 2013 at 1:45 PM, Peter Dimov
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.
The value_type typedef wasn't marked as deprecated in a comment or any other indication in the code itself. Of course the change is sensible, I just believe that breaking changes of components in the most widely used libraries in boost that have been present for multiple years are worth a mention in the release notes. :-) There are many interfaces and use cases all over boost that aren't in a detail namespace or otherwise marked as internal implementation details that are not mentioned or clear in the documentation :-) . They inevitably end up getting used, and while I'm personally happy to update interfaces to use improvements to libraries I've found around half the developers across two completely different organizations that I've worked at will get extremely grumpy if such changes don't come with adequate advanced notice. Some will even go so far as to avoid using libraries entirely after one or two breaking changes that cost them a lot of time. From their perspective I understand that it is helpful to be able to know when to expect a 5 minute boost update vs a 5 hour or even a 50 hour update. Of course, I'm in favor of improvements that break existing interfaces to make them better. I just want to convey some of the resistance I've encountered while advocating for boost and while updating it. 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
::element_**type is int and not int[]. This is not likely to be a problem in existing code, though.
Thanks! element_type worked for me. Cheers! Andrew Hundt
participants (3)
-
Andrew Hundt
-
Nathan Crookston
-
Peter Dimov