icecream-cpp
icecream-cpp copied to clipboard
Feature Request: Allow Printing Arrays of Data Types
Request: Add a new macro ICA(array, length)
that can print the array.
Example Usage:
int a[100] = {1, 2, 3, 4};
ICA(a+1, 2); // prints "ic| (a+1)[2]: [2, 3]"
pair<int, int> b[100] = {make_pair(5, 6), make_pair(7, 8)};
ICA(b, 2); // prints "ic| (b)[2]: [(5, 6), (7, 8)]"
vector<int> c(100, 5);
ICA(c.begin()+10, 3); // prints "ic| (c.begin()+10)[3]: [5, 5, 5]"
Usefulness:
-
Handling Large Arrays: When working with large arrays, it is often impractical to print the entire array for debugging purposes. This macro allows you to print only a small, relevant portion of the array, making the debugging process more efficient.
-
Support for Primitive Arrays: The macro is versatile and can handle primitive arrays, providing a convenient way to print and inspect arrays of basic data types without additional setup (e.g., use
std::ranges::views
orstd::vector
to create a class with iterators).