diff --git a/src/span.h b/src/span.h index 4931507719c..78c30fa5537 100644 --- a/src/span.h +++ b/src/span.h @@ -28,6 +28,14 @@ class Span C* m_data; std::size_t m_size; + template + struct is_Span_int : public std::false_type {}; + template + struct is_Span_int> : public std::true_type {}; + template + struct is_Span : public is_Span_int::type>{}; + + public: constexpr Span() noexcept : m_data(nullptr), m_size(0) {} @@ -78,8 +86,19 @@ public: * To prevent surprises, only Spans for constant value types are supported when passing in temporaries. * Note that this restriction does not exist when converting arrays or other Spans (see above). */ - template ::value || std::is_lvalue_reference::value) && std::is_convertible().data())>::type (*)[], C (*)[]>::value && std::is_convertible().size()), std::size_t>::value, int>::type = 0> - constexpr Span(V&& v) noexcept : m_data(v.data()), m_size(v.size()) {} + template + constexpr Span(V& other, + typename std::enable_if::value && + std::is_convertible().data())>::type (*)[], C (*)[]>::value && + std::is_convertible().size()), std::size_t>::value, std::nullptr_t>::type = nullptr) + : m_data(other.data()), m_size(other.size()){} + + template + constexpr Span(const V& other, + typename std::enable_if::value && + std::is_convertible().data())>::type (*)[], C (*)[]>::value && + std::is_convertible().size()), std::size_t>::value, std::nullptr_t>::type = nullptr) + : m_data(other.data()), m_size(other.size()){} constexpr C* data() const noexcept { return m_data; } constexpr C* begin() const noexcept { return m_data; }