diff --git a/include/gsl/span b/include/gsl/span index c7b45e9..3022e0d 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -740,11 +740,13 @@ span(std::array&)->span; template span(const std::array&)->span; -template -span(Container&)->span; +template ().data())>> +span(Container&)->span; -template -span(const Container&)->span; +template ().data())>> +span(const Container&)->span; #endif // ( defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201611L) ) diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index f53518b..d27d645 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -31,6 +31,13 @@ #include // for vector #include +#ifdef __has_include +#if __has_include() +#include +#define HAS_STRING_VIEW +#endif +#endif + using namespace std; using namespace gsl; @@ -1234,11 +1241,20 @@ TEST(span_test, from_array_constructor) { std::vector v{1,2,3,4}; gsl::span sp{v}; + static_assert(std::is_same>::value); } { std::string str{"foo"}; gsl::span sp{str}; + static_assert(std::is_same>::value); } +#ifdef HAS_STRING_VIEW + { + std::string_view sv{"foo"}; + gsl::span sp{sv}; + static_assert(std::is_same>::value); + } +#endif #endif }