Make C++ string_view detection work with MSVC

The existing method to check for support of C++17 `string_view` does not work on MSVC, see [here](https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=vs-2019)

Instead we replace with the [feature test macro](https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros) for `string_view`, which is `__cpp_lib_string_view`. This should work on all platforms and is arguably more precise.
This commit is contained in:
Christos Stratopoulos 2019-10-31 14:44:19 -04:00 committed by GitHub
parent 42fcc915e4
commit b607c4da9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,7 +23,7 @@ SOFTWARE.
#ifndef JWT_STRING_VIEW_HPP #ifndef JWT_STRING_VIEW_HPP
#define JWT_STRING_VIEW_HPP #define JWT_STRING_VIEW_HPP
#if __cplusplus >= 201703L #if defined(__cpp_lib_string_view)
#include <string_view> #include <string_view>
@ -31,7 +31,7 @@ namespace jwt {
using string_view = std::string_view; using string_view = std::string_view;
} }
#else // __cplusplus >= 201703L #else // defined(__cpp_lib_string_view)
#include <limits> #include <limits>
#include <string> #include <string>
@ -375,6 +375,6 @@ using string_view = basic_string_view<char>;
#include "jwt/impl/string_view.ipp" #include "jwt/impl/string_view.ipp"
#endif // __cplusplus >= 201703L #endif // defined(__cpp_lib_string_view)
#endif #endif