We have a template method that simplifies a call to std::dynamic_pointer_cast< std::shared_ptr<T> >(). However this method has actually two versions:
for not const pointers: std::shared_ptr<C> dynamicCast(const std::shared_ptr<T>&)
for const pointers : std::shared_ptr<const C> dynamicConstCast(const std::shared_ptr<const T>&)
I find the second version really misleading because one may think it does a std::const_cast<T>(), which means it would remove the const. Moreover this adds a unnecessary complexity since we can write a single function that handle both cases. This is what this pull request proposes to do.
I have not replaced every single dynamicConstCast in the code, but I can do it in a second commit if you think it is ok. Otherwise I think it is in both cases better to keep the method for some time until every occurrence is removed in other repositories.
We have a template method that simplifies a call to
std::dynamic_pointer_cast< std::shared_ptr<T> >()
. However this method has actually two versions:std::shared_ptr<C> dynamicCast(const std::shared_ptr<T>&)
std::shared_ptr<const C> dynamicConstCast(const std::shared_ptr<const T>&)
I find the second version really misleading because one may think it does a
std::const_cast<T>()
, which means it would remove the const. Moreover this adds a unnecessary complexity since we can write a single function that handle both cases. This is what this pull request proposes to do. I have not replaced every single dynamicConstCast in the code, but I can do it in a second commit if you think it is ok. Otherwise I think it is in both cases better to keep the method for some time until every occurrence is removed in other repositories.