Add visualizer for std::flat_map#4887
Merged
CaseyCarter merged 6 commits intomicrosoft:feature/flat_mapfrom Oct 24, 2024
Merged
Add visualizer for std::flat_map#4887CaseyCarter merged 6 commits intomicrosoft:feature/flat_mapfrom
std::flat_map#4887CaseyCarter merged 6 commits intomicrosoft:feature/flat_mapfrom
Conversation
CaseyCarter
suggested changes
Oct 23, 2024
Contributor
Author
|
I added a Code#include <deque>
#include <flat_map>
#include <map>
#include <string>
#include <unordered_map>
static void fillMap(auto &map) {
map.emplace(42, "hello world");
map.emplace(1, "meow");
map.emplace(2, "hey");
}
template <typename T> T make() {
T map{};
fillMap(map);
return map;
}
template <typename KeyContainer, typename MappedContainer> auto make() {
return make<std::flat_map<int, std::string, std::less<int>, KeyContainer,
MappedContainer>>();
}
int main() {
auto vectorVector = make<std::vector<int>, std::vector<std::string>>();
auto vectorDeque = make<std::vector<int>, std::deque<std::string>>();
auto dequeVector = make<std::deque<int>, std::vector<std::string>>();
auto dequeDeque = make<std::deque<int>, std::deque<std::string>>();
auto stdMap = make<std::map<int, std::string>>();
auto stdUnorderedMap = make<std::unordered_map<int, std::string>>();
return 0;
} |
CaseyCarter
approved these changes
Oct 24, 2024
Contributor
|
Thanks for yet another great piece of visualizer work! Truly visionary. 👁️🕶️👓🥽👀 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

This PR adds visualizers for
std::flat_mapwith any combination ofstd::vectorandstd::dequeas the backing containers.I'm not sure if there's a way of making this smaller. The only difference between the types is the implementation of
size,key_at, andvalue_at-<Expand>is always the same. Ideally, there would be a way of having a condition based on the relevant type in from the template ($T4forsizeandkey_at;$T5forvalue_at). Alternatively, it would be fine keeping just the type where both containers are vectors, since that's the default, and have the fallback that shows keys and values.Initially, I had aSee #4887 (comment)<DisplayString>{{ size={size()} }}</DisplayString>, but I wanted to have at least some preview of the items contained in the map in the unexpanded view. Unfortunately, the[comparator]still shows up in the display string, so only one value is shown.Code