Merge pull request #857 from pps83/master-natvis

Fix debugger visualizer for Ext=gsl::dynamic_extent
This commit is contained in:
Jordan Maples [MSFT] 2020-05-21 11:32:45 -07:00 committed by GitHub
commit 283e31478f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 45 deletions

View File

@ -19,9 +19,7 @@
</Expand> </Expand>
</Type> </Type>
<!-- These types are from the span header. --> <Type Name="gsl::span&lt;*, *&gt;">
<!-- This is for dynamic_extent spans. -->
<Type Name="gsl::span&lt;*, -1&gt;">
<DisplayString>{{ extent = {storage_.size_} }}</DisplayString> <DisplayString>{{ extent = {storage_.size_} }}</DisplayString>
<Expand> <Expand>
<ArrayItems> <ArrayItems>
@ -31,43 +29,7 @@
</Expand> </Expand>
</Type> </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;">
<DisplayString>{span_.storage_.data_,[span_.storage_.size_]na}</DisplayString>
<Expand>
<Item Name="[size]">span_.storage_.size_</Item>
<ArrayItems>
<Size>span_.storage_.size_</Size>
<ValuePointer>span_.storage_.data_</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<!-- This works for constexpr size string_spans. -->
<Type Name="gsl::basic_string_span&lt;*, *&gt;"> <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;">
<DisplayString>{span_.storage_.data_,[span_.storage_.size_]na}</DisplayString> <DisplayString>{span_.storage_.data_,[span_.storage_.size_]na}</DisplayString>
<Expand> <Expand>
<Item Name="[size]">span_.storage_.size_</Item> <Item Name="[size]">span_.storage_.size_</Item>
@ -77,19 +39,18 @@
</ArrayItems> </ArrayItems>
</Expand> </Expand>
</Type> </Type>
<!-- This works for constexpr size string_spans. -->
<Type Name="gsl::basic_zstring_span&lt;*, *&gt;"> <Type Name="gsl::basic_zstring_span&lt;*, *&gt;">
<DisplayString>{span_.storage_.data_,[span_.extent]na}</DisplayString> <DisplayString>{span_.storage_.data_,[span_.storage_.size_]na}</DisplayString>
<Expand> <Expand>
<Item Name="[size]">span_.extent</Item> <Item Name="[size]">span_.storage_.size_</Item>
<ArrayItems> <ArrayItems>
<Size>span_.extent</Size> <Size>span_.storage_.size_</Size>
<ValuePointer>span_.storage_.data_</ValuePointer> <ValuePointer>span_.storage_.data_</ValuePointer>
</ArrayItems> </ArrayItems>
</Expand> </Expand>
</Type> </Type>
<!-- These types are from the gsl header. --> <!-- These types are from the gsl header. -->
<Type Name="gsl::not_null&lt;*&gt;"> <Type Name="gsl::not_null&lt;*&gt;">
<!-- We can always dereference this since it's an invariant. --> <!-- We can always dereference this since it's an invariant. -->

View File

@ -348,6 +348,13 @@ namespace details
constexpr explicit extent_type(size_type size) { Expects(size == Ext); } constexpr explicit extent_type(size_type size) { Expects(size == Ext); }
constexpr size_type size() const noexcept { return 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 <> template <>