From 830b081de7136c9ed7da1b08067680fcb2303f4a Mon Sep 17 00:00:00 2001 From: Pavel P Date: Fri, 27 Mar 2020 13:14:23 +0600 Subject: [PATCH] Fix debugger visualizer for Ext=gsl::dynamic_extent VS 2019 doesn't seem to match -1 for size_t template parameter, as a result dynamic span/basic_string_span/basic_zstring_span show extent as `extent = 4294967295` (for 32-bit builds). This change updates details::extent_type to have static constexpr size_ parameter for non-dynamic span/basic_string_span/basic_zstring_span and simplifies/removes dynamic versions from GSL.natvis fixes #856 --- GSL.natvis | 47 ++++------------------------------------------- include/gsl/span | 7 +++++++ 2 files changed, 11 insertions(+), 43 deletions(-) diff --git a/GSL.natvis b/GSL.natvis index a467a17de..1bf27a5c5 100644 --- a/GSL.natvis +++ b/GSL.natvis @@ -19,9 +19,7 @@ - - - + {{ extent = {storage_.size_} }} @@ -31,19 +29,7 @@ - - - {{ extent = {extent} }} - - - extent - storage_.data_ - - - - - - + {span_.storage_.data_,[span_.storage_.size_]na} span_.storage_.size_ @@ -54,20 +40,7 @@ - - - {span_.storage_.data_,[span_.extent]na} - - span_.extent - - span_.extent - span_.storage_.data_ - - - - - - + {span_.storage_.data_,[span_.storage_.size_]na} span_.storage_.size_ @@ -77,19 +50,7 @@ - - - - {span_.storage_.data_,[span_.extent]na} - - span_.extent - - span_.extent - span_.storage_.data_ - - - - + diff --git a/include/gsl/span b/include/gsl/span index 23c58c920..82fe58bac 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -355,6 +355,13 @@ namespace details constexpr extent_type(size_type size) { Expects(size == Ext); } constexpr size_type size() const noexcept { return Ext; } + + private: +#if defined(GSL_USE_STATIC_CONSTEXPR_WORKAROUND) + static constexpr const size_type size_ = Ext; // static size equal to Ext +#else + static constexpr size_type size_ = Ext; // static size equal to Ext +#endif }; template <>