Goose is a small utility library which supports inserting STL collection-like types to the output streams. It also provides stringification of such collections.
Supported C++ standard versions are 17 and 20. Linux and Mac are tested on the CI. Support for Windows is not guaranteed.
- Goose can be used as single header library from the release version.
- Another way of using Goose is to add this repo as a submodule. Currently, only CMake is supported as a build system.
One-dimensional vector:
std::vector<int> vec{1, 2, 3, 4};
std::cout << vec << std::endl;
Output:
[1, 2, 3, 4]
Two-dimensional vector (I'm not saying you should use this example in production :D):
using Vec2 = std::vector<std::vector<int>>;
Vec2 vec2{{1, 2, 3, 4}, {-1, -2, -3, -4}, {42, -68}};
std::cout << vec2 << std::endl;
Output:
{[1, 2, 3, 4],
[-1, -2, -3, -4],
[42, -68]}
using HashMap = std::unordered_map<std::string, int>;
HashMap map{{"some", 42}, {"random", 600}, {"words", 68}};
auto stringified_map = gos::to_string(map);
std::printf("Stringified map: %s\n", stringified_map.c_str());
Possible output:
Stringified map: [[words, 68], [random, 600], [some, 42]]