mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
fcdff2f205
The current implementation of gsl::not_null provides a constructor to convert from not_null<U> to not_null<T> when there exists an implicit conversion from U to T. However it does not provide an easy way to convert from not_null<U> to not_null<T> when the conversion from U to T requires the use of static_cast. Manually, one would have to do: auto converted = gsl::not_null<T>(static_cast<T>(original.get())) In accordance with the STL naming conventions, I propose the function "gsl::static_pointer_cast(gsl::not_null<U> const &)" to do the job. Until the GSL gets merged with the STL, it would lie on the ::gsl namespace, instead of being on ::std along with static_pointer_cast(std::shared_ptr<U> const &). Note 1: We could add noexcept if not_null's constructor were noexcept. Note 2: dynamic_pointer_cast should not be implemented, since dynamic_cast can return nullptr. |
||
---|---|---|
.. | ||
fail_fast.h | ||
gsl.h | ||
span.h | ||
string_span.h |