Merge pull request #769 from jack17529/patch-1

Update usage of difference_type in span
diff --git a/appveyor.yml b/appveyor.yml
index c3e3c87..6feaf7c 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -11,6 +11,7 @@
 image:
   - Visual Studio 2015
   - Visual Studio 2017
+  - Visual Studio 2019
 
 environment:
   NINJA_TAG: v1.8.2
@@ -18,6 +19,7 @@
   NINJA_PATH: C:\Tools\ninja\ninja-%NINJA_TAG%
   VCVAR2015: 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat'
   VCVAR2017: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat'
+  VCVAR2019: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat'
   matrix:
     - GSL_CXX_STANDARD: 14
       USE_TOOLSET: MSVC
@@ -41,7 +43,7 @@
       USE_GENERATOR: MSBuild
 
 cache:
-  - C:\cmake-3.8.0-win32-x86
+  - C:\cmake-3.14.4-win32-x86
   - C:\Tools\ninja
 
 install:
@@ -58,11 +60,11 @@
         $env:PATH = "$env:NINJA_PATH;$env:PATH"
       } else { Write-Warning "Failed to find ninja.exe in expected location." }
       if ($env:USE_TOOLSET -ne "LLVM") {
-        if (![IO.File]::Exists("C:\cmake-3.8.0-win32-x86\bin\cmake.exe")) {
-          Start-FileDownload 'https://cmake.org/files/v3.8/cmake-3.8.0-win32-x86.zip'
-          7z x -y -bso0 cmake-3.8.0-win32-x86.zip -oC:\
+        if (![IO.File]::Exists("C:\cmake-3.14.0-win32-x86\bin\cmake.exe")) {
+          Start-FileDownload 'https://cmake.org/files/v3.14/cmake-3.14.4-win32-x86.zip'
+          7z x -y -bso0 cmake-3.14.4-win32-x86.zip -oC:\
         }
-        $env:PATH="C:\cmake-3.8.0-win32-x86\bin;$env:PATH"
+        $env:PATH="C:\cmake-3.14.4-win32-x86\bin;$env:PATH"
       }
 
 before_build:
@@ -72,16 +74,20 @@
         $Architecture = $env:PLATFORM
         if ("$env:APPVEYOR_BUILD_WORKER_IMAGE" -eq "Visual Studio 2015") {
           $env:VCVARSALL = "`"$env:VCVAR2015`" $Architecture"
-        } else {
+        } elseif ("$env:APPVEYOR_BUILD_WORKER_IMAGE" -eq "Visual Studio 2017") {
           $env:VCVARSALL = "`"$env:VCVAR2017`" $Architecture"
+        } else {
+          $env:VCVARSALL = "`"$env:VCVAR2019`" $Architecture"
         }
         $env:CMakeGenFlags = "-G Ninja -DGSL_CXX_STANDARD=$env:GSL_CXX_STANDARD"
       } else {
         $GeneratorFlags = '/m /v:minimal'
         if ("$env:APPVEYOR_BUILD_WORKER_IMAGE" -eq "Visual Studio 2015") {
           $Generator = 'Visual Studio 14 2015'
-        } else {
+        } elseif ("$env:APPVEYOR_BUILD_WORKER_IMAGE" -eq "Visual Studio 2017") {
           $Generator = 'Visual Studio 15 2017'
+        } else {
+          $Generator = 'Visual Studio 16 2019'
         }
         if ("$env:PLATFORM" -eq "x86") { 
             $Architecture = "Win32"
diff --git a/include/gsl/gsl_byte b/include/gsl/gsl_byte
index 861446d..1670646 100644
--- a/include/gsl/gsl_byte
+++ b/include/gsl/gsl_byte
@@ -56,6 +56,7 @@
 #else // _MSC_VER
 
 #ifndef GSL_USE_STD_BYTE
+#include <cstddef> /* __cpp_lib_byte */
 // this tests if we are under GCC or Clang with enough -std:c++1z power to get us std::byte
 // also check if libc++ version is sufficient (> 5.0) or libstc++ actually contains std::byte
 #if defined(__cplusplus) && (__cplusplus >= 201703L) && \
@@ -63,7 +64,6 @@
    defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 5000))
 
 #define GSL_USE_STD_BYTE 1
-#include <cstddef>
 
 #else // defined(__cplusplus) && (__cplusplus >= 201703L) &&
       //   (defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603)  ||
diff --git a/include/gsl/gsl_util b/include/gsl/gsl_util
index 4addde6..0fce689 100644
--- a/include/gsl/gsl_util
+++ b/include/gsl/gsl_util
@@ -37,7 +37,7 @@
 #endif            // _MSC_VER < 1910
 #endif            // _MSC_VER
 
-#if (defined(_MSC_VER) && _MSC_VER < 1910) || (!defined(__clang__) && defined(__GNUC__) && __GUNC__ < 6)
+#if (defined(_MSC_VER) && _MSC_VER < 1910) || (!defined(__clang__) && defined(__GNUC__) && __GNUC__ < 6)
 #define GSL_CONSTEXPR_NARROW 0
 #else
 #define GSL_CONSTEXPR_NARROW 1
diff --git a/include/gsl/multi_span b/include/gsl/multi_span
index f1a909e..0c1506e 100644
--- a/include/gsl/multi_span
+++ b/include/gsl/multi_span
@@ -518,31 +518,31 @@
     struct TypeListIndexer
     {
         const TypeChain& obj_;
-        TypeListIndexer(const TypeChain& obj) : obj_(obj) {}
+        constexpr TypeListIndexer(const TypeChain& obj) : obj_(obj) {}
 
         template <std::size_t N>
-        const TypeChain& getObj(std::true_type)
+        constexpr const TypeChain& getObj(std::true_type)
         {
             return obj_;
         }
 
         template <std::size_t N, typename MyChain = TypeChain,
                   typename MyBase = typename MyChain::Base>
-        auto getObj(std::false_type)
+        constexpr auto getObj(std::false_type)
             -> decltype(TypeListIndexer<MyBase>(static_cast<const MyBase&>(obj_)).template get<N>())
         {
             return TypeListIndexer<MyBase>(static_cast<const MyBase&>(obj_)).template get<N>();
         }
 
         template <std::size_t N>
-        auto get() -> decltype(getObj<N - 1>(std::integral_constant<bool, N == 0>()))
+        constexpr auto get() -> decltype(getObj<N - 1>(std::integral_constant<bool, N == 0>()))
         {
             return getObj<N - 1>(std::integral_constant<bool, N == 0>());
         }
     };
 
     template <typename TypeChain>
-    TypeListIndexer<TypeChain> createTypeListIndexer(const TypeChain& obj)
+    constexpr TypeListIndexer<TypeChain> createTypeListIndexer(const TypeChain& obj)
     {
         return TypeListIndexer<TypeChain>(obj);
     }
diff --git a/include/gsl/string_span b/include/gsl/string_span
index b5dfd18..37cbe15 100644
--- a/include/gsl/string_span
+++ b/include/gsl/string_span
@@ -20,7 +20,6 @@
 #include <gsl/gsl_assert> // for Ensures, Expects
 #include <gsl/gsl_util>   // for narrow_cast
 #include <gsl/span>       // for operator!=, operator==, dynamic_extent
-#include <gsl/pointers>   // for not_null
 
 #include <algorithm> // for equal, lexicographical_compare
 #include <array>     // for array
@@ -175,6 +174,7 @@
 {
 public:
     using element_type = CharT;
+    using value_type = std::remove_cv_t<element_type>;
     using pointer = std::add_pointer_t<element_type>;
     using reference = std::add_lvalue_reference_t<element_type>;
     using const_reference = std::add_lvalue_reference_t<std::add_const_t<element_type>>;
@@ -186,6 +186,8 @@
     using reverse_iterator = typename impl_type::reverse_iterator;
     using const_reverse_iterator = typename impl_type::const_reverse_iterator;
 
+    using size_type = index_type;
+
     // default (empty)
     constexpr basic_string_span() noexcept = default;