Skip to content

STL.natvis: ranges::view_interface doesn't always have size() #4830

@StephanTLavavej

Description

@StephanTLavavej

STL/stl/inc/xutility

Lines 3766 to 3779 in ef1d621

_NODISCARD constexpr auto size()
requires forward_range<_Derived> && sized_sentinel_for<sentinel_t<_Derived>, iterator_t<_Derived>>
{
auto& _Self = _Cast();
return _STD _To_unsigned_like(_RANGES end(_Self) - _RANGES begin(_Self));
}
_NODISCARD constexpr auto size() const
requires forward_range<const _Derived>
&& sized_sentinel_for<sentinel_t<const _Derived>, iterator_t<const _Derived>>
{
auto& _Self = _Cast();
return _STD _To_unsigned_like(_RANGES end(_Self) - _RANGES begin(_Self));
}

STL/stl/debugger/STL.natvis

Lines 2004 to 2012 in ef1d621

<Type Name="std::ranges::view_interface&lt;*&gt;">
<DisplayString>{{ size={size()} }}</DisplayString>
<Expand>
<Item Optional="true" Name="empty">empty()</Item>
<Item Optional="true" Name="front">front()</Item>
<Item Optional="true" Name="back">back()</Item>
<Item Optional="true" Name="data">data()</Item>
</Expand>
</Type>

Reported by @xiangfan-ms:

The 'size' member function doesn't always exist in the specialization. When this happens, the entry will be ignored by the debugger.

Present since this visualizer was added by #2191 on 2022-07-11 in VS 2022 17.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!visualizerHow the VS debugger displays STL types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions