microsoft / GSL

Guidelines Support Library
Other
6.13k stars 737 forks source link

Documentation #1086

Closed beinhaerter closed 1 year ago

beinhaerter commented 1 year ago

This is a first (partial) shot for issue #1071.

beinhaerter commented 1 year ago

As the reviews seems to take some time, I have now completed the docs.

dmitrykobets-msft commented 1 year ago

@beinhaerter I left one last comment - after this it should be good to merge. thanks for being patient!

beinhaerter commented 1 year ago

If I assembled it correctly, then your proposed change is:

template <class OtherElementType, std::size_t OtherExtent>
explicit(Extent == gsl::dynamic_extent || Extent == OtherExtent)
constexpr span(const span<OtherElementType, OtherExtent>& other) noexcept;

template <class OtherElementType, std::size_t OtherExtent>
explicit(Extent != gsl::dynamic_extent && OtherExtent == Extent)
constexpr explicit span(const span<OtherElementType, OtherExtent>& other) noexcept;

Constructs a span from another span, allowing construction from a span of different extent and element type.

This is not correct. The first ctor is not explicit. The second ctor is always explicit, so the line with only the explicit should be removed. The new comment does not mention that there are constraints for ElementType and OtherElementType. The new comment does not mention that you cannot construct a gsl::span<T, 3> from a gsl::span<T, something_other_than_3>.

But I now see that my comments for the enablement were also false. The second enable_if slightly differs from the first one.

dmitrykobets-msft commented 1 year ago

Thanks for the PR, looks good!