Skip to content

Commit 92f1f4f

Browse files
committed
Update consolidated snippets
1 parent 14986ee commit 92f1f4f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

public/consolidated/cpp.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@
3232
}
3333
]
3434
},
35+
{
36+
"categoryName": "Debugging",
37+
"snippets": [
38+
{
39+
"title": "Vector Print",
40+
"description": "Overloads the << operator to print the contents of a vector just like in python.",
41+
"author": "Mohamed-faaris",
42+
"tags": [
43+
"printing",
44+
"debuging",
45+
"vector"
46+
],
47+
"contributors": [],
48+
"code": "#include <iostream> \n#include <vector> \n\ntemplate <typename T>\nstd::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {\n os << \"[\"; \n for (size_t i = 0; i < vec.size(); ++i) {\n os << vec[i]; // Print each vector element\n if (i != vec.size() - 1) {\n os << \", \"; // Add separator\n }\n }\n os << \"]\"; \n return os; // Return the stream\n}\n\n// Usage:\nstd::vector<int> numbers = {1, 2, 3, 4, 5};\nstd::cout << numbers << std::endl; // Outputs: [1, 2, 3, 4, 5]\n\n"
49+
}
50+
]
51+
},
3552
{
3653
"categoryName": "Debuging",
3754
"snippets": [

0 commit comments

Comments
 (0)