Add some comment blocks

pull/13881/head
Marc Emmers 2021-01-16 21:04:16 +01:00
parent f7e19b5232
commit 78f2cfc0d9
1 changed files with 23 additions and 0 deletions

View File

@ -17,6 +17,14 @@
#ifndef MSTD_SPAN_
#define MSTD_SPAN_
/* <mstd_span>
*
* - Includes toolchain's <span> if available
* - Otherwise provides an implementation of a C++20 equivalent std::span
* - deduction guides available from C++17 and on
* - provides nonstandard mstd::make_span functions to allow deduction pre C++17
*/
#if __cplusplus >= 201703L && __has_include(<span>)
#include <version>
#endif
@ -341,6 +349,11 @@ template<class R>
span(R&&) -> span<remove_reference_t<detail::range_reference_t<R>>>;
#endif
/** Create a span class with type and size inferred from the argument
*
* @param arr Reference to a c-style array
* @return Span with inferred type and size Extent
*/
template<class ElementType, size_t Extent>
constexpr span<ElementType, Extent> make_span(ElementType (&arr)[Extent])
{
@ -353,6 +366,11 @@ constexpr span<const ElementType, Extent> make_span(const ElementType (&arr)[Ext
return arr;
}
/** Create a span class with type and size inferred from the argument
*
* @param arr Reference to an std::array
* @return Span with inferred type and size Extent
*/
template<class ElementType, size_t Extent>
constexpr span<ElementType, Extent> make_span(std::array<ElementType, Extent> &arr)
{
@ -365,6 +383,11 @@ constexpr span<const ElementType, Extent> make_span(const std::array<ElementType
return arr;
}
/** Create a span class with type inferred from the argument
*
* @param cont Reference to a container
* @return Span with inferred type and dynamic size
*/
template<class R>
constexpr span<typename R::value_type> make_span(R &cont)
{