1717#ifndef MSTD_SPAN_
1818#define MSTD_SPAN_
1919
20+ /* <mstd_span>
21+ *
22+ * - Includes toolchain's <span> if available
23+ * - Otherwise provides an implementation of a C++20 equivalent std::span
24+ * - deduction guides available from C++17 and on
25+ * - provides nonstandard mstd::make_span functions to allow deduction pre C++17
26+ */
27+
2028#if __cplusplus >= 201703L && __has_include(<span>)
2129#include <version>
2230#endif
@@ -341,6 +349,11 @@ template<class R>
341349span(R&&) -> span<remove_reference_t<detail::range_reference_t<R>>>;
342350#endif
343351
352+ /** Create a span class with type and size inferred from the argument
353+ *
354+ * @param arr Reference to a c-style array
355+ * @return Span with inferred type and size Extent
356+ */
344357template<class ElementType, size_t Extent>
345358constexpr span<ElementType, Extent> make_span(ElementType (&arr)[Extent])
346359{
@@ -353,6 +366,11 @@ constexpr span<const ElementType, Extent> make_span(const ElementType (&arr)[Ext
353366 return arr;
354367}
355368
369+ /** Create a span class with type and size inferred from the argument
370+ *
371+ * @param arr Reference to an std::array
372+ * @return Span with inferred type and size Extent
373+ */
356374template<class ElementType, size_t Extent>
357375constexpr span<ElementType, Extent> make_span(std::array<ElementType, Extent> &arr)
358376{
@@ -365,6 +383,11 @@ constexpr span<const ElementType, Extent> make_span(const std::array<ElementType
365383 return arr;
366384}
367385
386+ /** Create a span class with type inferred from the argument
387+ *
388+ * @param cont Reference to a container
389+ * @return Span with inferred type and dynamic size
390+ */
368391template<class R>
369392constexpr span<typename R::value_type> make_span(R &cont)
370393{
0 commit comments