|
32 | 32 | }
|
33 | 33 | ]
|
34 | 34 | },
|
| 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 | + }, |
35 | 52 | {
|
36 | 53 | "categoryName": "Debuging",
|
37 | 54 | "snippets": [
|
|
0 commit comments