martinmoene / span-lite

span lite - A C++20-like span for C++98, C++11 and later in a single-file header-only library
Boost Software License 1.0
495 stars 40 forks source link

span_HAVE_DEDUCTION_GUIDES deduction on MSVC fails #38

Closed melak47 closed 4 years ago

melak47 commented 5 years ago

span_HAVE_DEDUCTION_GUIDES is defined like this:

#define span_HAVE_DEDUCTION_GUIDES         (span_CPP17_OR_GREATER && ! span_BETWEEN( span_COMPILER_MSVC_VERSION, 1, 999 ))

which excludes the feature on all MSVC versions... even though right above a comment notes:

// MSVC: template parameter deduction guides since Visual Studio 2017 v15.7

I can only find two other feature tests that use span_COMPILER_MSVC_VERSION rather than span_COMPILER_MSVC_VER. Would it be acceptable to just change those?

e.g.

--- a/span.hpp
+++ b/span.hpp
@@ -243,7 +241,7 @@ using std::span;
 # pragma GCC   diagnostic ignored "-Wundef"
 # define span_RESTORE_WARNINGS()   _Pragma( "GCC diagnostic pop" )

-#elif span_COMPILER_MSVC_VERSION >= 140
+#elif span_COMPILER_MSVC_VER >= 1900
 # define span_DISABLE_MSVC_WARNINGS(codes)  __pragma(warning(push))  __pragma(warning(disable: codes))
 # define span_RESTORE_WARNINGS()            __pragma(warning(pop ))

@@ -311,7 +309,7 @@ span_DISABLE_MSVC_WARNINGS( 26439 26440 26472 26473 26481 26490 )

 // MSVC: template parameter deduction guides since Visual Studio 2017 v15.7

-#define span_HAVE_DEDUCTION_GUIDES         (span_CPP17_OR_GREATER && ! span_BETWEEN( span_COMPILER_MSVC_VERSION, 1, 999 ))
+#define span_HAVE_DEDUCTION_GUIDES         (span_CPP17_OR_GREATER && ! span_BETWEEN( span_COMPILER_MSVC_VER, 1, 1913 ))

 // Presence of C++ library features:

@@ -319,7 +317,7 @@ span_DISABLE_MSVC_WARNINGS( 26439 26440 26472 26473 26481 26490 )
 #define span_HAVE_ARRAY                     span_CPP11_110
 #define span_HAVE_BYTE                      span_CPP17_000
 #define span_HAVE_CONDITIONAL               span_CPP11_120
-#define span_HAVE_CONTAINER_DATA_METHOD    (span_CPP11_140 || ( span_COMPILER_MSVC_VERSION >= 90 && span_HAS_CPP0X ))
+#define span_HAVE_CONTAINER_DATA_METHOD    (span_CPP11_140 || ( span_COMPILER_MSVC_VER >= 1500 && span_HAS_CPP0X ))
 #define span_HAVE_DATA                      span_CPP17_000
 #define span_HAVE_LONGLONG                  span_CPP11_80
 #define span_HAVE_REMOVE_CONST              span_CPP11_110
flexferrum commented 4 years ago

PR is welcome!