You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Actually I tested it and I think std::ranges::view_interface natvis may be useless.
My test code:
#include <iostream>
#include <ranges>
#include <vector>
#include <sstream>
template<class T, class A>
class VectorView : public std::ranges::view_interface<VectorView<T, A>>
{
public:
VectorView() = default;
VectorView(const std::vector<T, A>& vec) :
m_begin(vec.cbegin()), m_end(vec.cend())
{}
auto begin() const { return m_begin; }
auto end() const { return m_end; }
private:
typename std::vector<T, A>::const_iterator m_begin{}, m_end{};
};
int main()
{
std::vector<int> v = { 1, 4, 9, 16 };
VectorView view1{ v };
view1.size();
view1.front();
view1.empty();
view1.back();
view1.data();
auto words = std::istringstream{ "today is yesterdayβs tomorrow" };
auto istream_view = std::views::istream<std::string>(words);;
std::ranges::view_interface<std::ranges::basic_istream_view<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, char, std::char_traits<char> > > view2 = istream_view;
return 0;
}
For std::ranges::view_interface without size() I used istream_view.
For std::ranges::view_interface withsize() I used VectorView from https://en.cppreference.com/w/cpp/ranges/view_interface
I also called size(), front(), empty(), back(), data() because the compiler didn't generate these methods by default and Natvis showed unknown size.
My results:
As I can see Natvis never calls methods. It works great only for memory variables and intrinsics.
iota_view example:
And because std::ranges::view_interface is dependent from _Derived, we can't create an intrinsic for its size.
Am I correct and we always will receive "???" or "This expression has side effects and will not be evaluate"?
Hmm, this does seem like an inherently not-useful/not-implementable visualizer. I think we should simply remove it, and then if someone identifies a scenario in which it can be usefully implemented, we can add a working version later.
bugSomething isn't workingvisualizerHow the VS debugger displays STL types
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4830
Actually I tested it and I think
std::ranges::view_interface
natvis may be useless.My test code:
For
std::ranges::view_interface
withoutsize()
I usedistream_view
.For
std::ranges::view_interface
withsize()
I usedVectorView
from https://en.cppreference.com/w/cpp/ranges/view_interfaceI also called
size()
,front()
,empty()
,back()
,data()
because the compiler didn't generate these methods by default and Natvis showedunknown size
.My results:

As I can see Natvis never calls methods. It works great only for memory variables and intrinsics.
iota_view example:
And because
std::ranges::view_interface
is dependent from_Derived
, we can't create an intrinsic for its size.Am I correct and we always will receive "???" or "This expression has side effects and will not be evaluate"?