Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debugger visualizer for Ext=gsl::dynamic_extent #857

Merged
merged 1 commit into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 4 additions & 43 deletions GSL.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
</Expand>
</Type>

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

<!-- This works for constexpr size spans. -->
<Type Name="gsl::span&lt;*, *&gt;">
<DisplayString>{{ extent = {extent} }}</DisplayString>
<Expand>
<ArrayItems>
<Size>extent</Size>
<ValuePointer>storage_.data_</ValuePointer>
</ArrayItems>
</Expand>
</Type>

<!-- This is for dynamic_extent string_spans. -->
<Type Name="gsl::basic_string_span&lt;*, -1&gt;">
<Type Name="gsl::basic_string_span&lt;*, *&gt;">
<DisplayString>{span_.storage_.data_,[span_.storage_.size_]na}</DisplayString>
<Expand>
<Item Name="[size]">span_.storage_.size_</Item>
Expand All @@ -54,20 +40,7 @@
</Expand>
</Type>

<!-- This works for constexpr size string_spans. -->
<Type Name="gsl::basic_string_span&lt;*, *&gt;">
<DisplayString>{span_.storage_.data_,[span_.extent]na}</DisplayString>
<Expand>
<Item Name="[size]">span_.extent</Item>
<ArrayItems>
<Size>span_.extent</Size>
<ValuePointer>span_.storage_.data_</ValuePointer>
</ArrayItems>
</Expand>
</Type>

<!-- This is for dynamic_extent zstring_spans. -->
<Type Name="gsl::basic_zstring_span&lt;*, -1&gt;">
<Type Name="gsl::basic_zstring_span&lt;*, *&gt;">
<DisplayString>{span_.storage_.data_,[span_.storage_.size_]na}</DisplayString>
<Expand>
<Item Name="[size]">span_.storage_.size_</Item>
Expand All @@ -77,19 +50,7 @@
</ArrayItems>
</Expand>
</Type>

<!-- This works for constexpr size string_spans. -->
<Type Name="gsl::basic_zstring_span&lt;*, *&gt;">
<DisplayString>{span_.storage_.data_,[span_.extent]na}</DisplayString>
<Expand>
<Item Name="[size]">span_.extent</Item>
<ArrayItems>
<Size>span_.extent</Size>
<ValuePointer>span_.storage_.data_</ValuePointer>
</ArrayItems>
</Expand>
</Type>


<!-- These types are from the gsl header. -->
<Type Name="gsl::not_null&lt;*&gt;">
<!-- We can always dereference this since it's an invariant. -->
Expand Down
7 changes: 7 additions & 0 deletions include/gsl/span
Original file line number Diff line number Diff line change
Expand Up @@ -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 <>
Expand Down