How to use the smartpointer overloads inside `<span_ext>`?
dmitrykobets-msft opened this issue · comments
There are two overloads for gsl::make_span
which take a Ptr
that has an element_type
class member. Presumably this was introduced to handle smartpointers. However, since gsl::span
itself doesn't have a way to construct a span from a smartpointer, and there is no implicit conversion from a STL smartpointer to a raw pointer, the following code doesn't compile anyways with the current implementation:
#include <gsl/span>
#include <memory>
int main()
{
std::unique_ptr<int> a(new int(42));
gsl::span<int> s = gsl::make_span(a);
}
The two overloads in <span_ext>
:
template <class Ptr>
constexpr span<typename Ptr::element_type> make_span(Ptr& cont, std::size_t count)
{
return span<typename Ptr::element_type>(cont, count);
}
template <class Ptr>
constexpr span<typename Ptr::element_type> make_span(Ptr& cont)
{
return span<typename Ptr::element_type>(cont);
}
Editors call: Deprecate these functions.