Skip to content

Commit 830b081

Browse files
committed
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 microsoft#856
1 parent 226a854 commit 830b081

File tree

2 files changed

+11
-43
lines changed

2 files changed

+11
-43
lines changed

GSL.natvis

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
</Expand>
2020
</Type>
2121

22-
<!-- These types are from the span header. -->
23-
<!-- This is for dynamic_extent spans. -->
24-
<Type Name="gsl::span&lt;*, -1&gt;">
22+
<Type Name="gsl::span&lt;*, *&gt;">
2523
<DisplayString>{{ extent = {storage_.size_} }}</DisplayString>
2624
<Expand>
2725
<ArrayItems>
@@ -31,19 +29,7 @@
3129
</Expand>
3230
</Type>
3331

34-
<!-- This works for constexpr size spans. -->
35-
<Type Name="gsl::span&lt;*, *&gt;">
36-
<DisplayString>{{ extent = {extent} }}</DisplayString>
37-
<Expand>
38-
<ArrayItems>
39-
<Size>extent</Size>
40-
<ValuePointer>storage_.data_</ValuePointer>
41-
</ArrayItems>
42-
</Expand>
43-
</Type>
44-
45-
<!-- This is for dynamic_extent string_spans. -->
46-
<Type Name="gsl::basic_string_span&lt;*, -1&gt;">
32+
<Type Name="gsl::basic_string_span&lt;*, *&gt;">
4733
<DisplayString>{span_.storage_.data_,[span_.storage_.size_]na}</DisplayString>
4834
<Expand>
4935
<Item Name="[size]">span_.storage_.size_</Item>
@@ -54,20 +40,7 @@
5440
</Expand>
5541
</Type>
5642

57-
<!-- This works for constexpr size string_spans. -->
58-
<Type Name="gsl::basic_string_span&lt;*, *&gt;">
59-
<DisplayString>{span_.storage_.data_,[span_.extent]na}</DisplayString>
60-
<Expand>
61-
<Item Name="[size]">span_.extent</Item>
62-
<ArrayItems>
63-
<Size>span_.extent</Size>
64-
<ValuePointer>span_.storage_.data_</ValuePointer>
65-
</ArrayItems>
66-
</Expand>
67-
</Type>
68-
69-
<!-- This is for dynamic_extent zstring_spans. -->
70-
<Type Name="gsl::basic_zstring_span&lt;*, -1&gt;">
43+
<Type Name="gsl::basic_zstring_span&lt;*, *&gt;">
7144
<DisplayString>{span_.storage_.data_,[span_.storage_.size_]na}</DisplayString>
7245
<Expand>
7346
<Item Name="[size]">span_.storage_.size_</Item>
@@ -77,19 +50,7 @@
7750
</ArrayItems>
7851
</Expand>
7952
</Type>
80-
81-
<!-- This works for constexpr size string_spans. -->
82-
<Type Name="gsl::basic_zstring_span&lt;*, *&gt;">
83-
<DisplayString>{span_.storage_.data_,[span_.extent]na}</DisplayString>
84-
<Expand>
85-
<Item Name="[size]">span_.extent</Item>
86-
<ArrayItems>
87-
<Size>span_.extent</Size>
88-
<ValuePointer>span_.storage_.data_</ValuePointer>
89-
</ArrayItems>
90-
</Expand>
91-
</Type>
92-
53+
9354
<!-- These types are from the gsl header. -->
9455
<Type Name="gsl::not_null&lt;*&gt;">
9556
<!-- We can always dereference this since it's an invariant. -->

include/gsl/span

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,13 @@ namespace details
355355
constexpr extent_type(size_type size) { Expects(size == Ext); }
356356

357357
constexpr size_type size() const noexcept { return Ext; }
358+
359+
private:
360+
#if defined(GSL_USE_STATIC_CONSTEXPR_WORKAROUND)
361+
static constexpr const size_type size_ = Ext; // static size equal to Ext
362+
#else
363+
static constexpr size_type size_ = Ext; // static size equal to Ext
364+
#endif
358365
};
359366

360367
template <>

0 commit comments

Comments
 (0)