Skip to content

Commit 7a3b354

Browse files
committed
c++ container
1 parent 9b58454 commit 7a3b354

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

gdb/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Tested on 7.7.1 unless mentioned otherwise.
2121
1. [define](define.c)
2222
1. [stderr ignore](stderr_ignore.c)
2323
1. C++ features
24+
1. [Containers](container.cpp)
2425
1. [Overload](overload.cpp)
2526
1. [Method](method.cpp)
2627
1. [Polymorphism](polymorphism.cpp)

gdb/container.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
- https://stackoverflow.com/questions/11606048/how-to-pretty-print-stl-containers-in-gdb
3+
- https://stackoverflow.com/questions/253099/how-do-i-print-the-elements-of-a-c-vector-in-gdb
4+
- https://stackoverflow.com/questions/427589/inspecting-standard-container-stdmap-contents-with-gdb
5+
*/
6+
7+
#include <map>
8+
#include <utility>
9+
#include <vector>
10+
11+
int main() {
12+
std::vector<int> v;
13+
v.push_back(0);
14+
v.push_back(1);
15+
v.push_back(2);
16+
std::map<int,int> m;
17+
m.insert(std::make_pair(0, 0));
18+
m.insert(std::make_pair(1, -1));
19+
m.insert(std::make_pair(2, -2));
20+
}

0 commit comments

Comments
 (0)