GSL/include
Samuel García Salas fcdff2f205 Add static_pointer_cast
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.
2015-11-14 03:05:59 +01:00
..
fail_fast.h Commit to address issue #103... 2015-09-30 12:50:42 -04:00
gsl.h Add static_pointer_cast 2015-11-14 03:05:59 +01:00
span.h Turned on Level 3 warnings for MSVC. 2015-11-12 18:57:23 -08:00
string_span.h Cast size_type for string_span ctor from container. 2015-11-11 20:48:42 -08:00