diff --git a/src/helpers/debug.h b/src/helpers/debug.h index fcfb6745..6d5ad6aa 100644 --- a/src/helpers/debug.h +++ b/src/helpers/debug.h @@ -3,16 +3,32 @@ #ifdef __cplusplus #include +#include #endif namespace DEBUG { template - void print_arguments(T &&t) { // single argument + void print_arguments(const T &t) { // single argument std::cout << t << ' '; } + template + void print_arguments(const std::vector &t){ // vectors as arguments + for(const T& x : t) { + std::cout << x << ' '; + } + } + + template + void print_arguments(const std::vector &t, Args&& ...args) { // multiple args + for(const T& x : t) { + std::cout << x << ' '; + } + print_arguments(std::forward(args)...); + } + template - void print_arguments(T &&t, Args&& ...args) { // multiple arguments + void print_arguments(const T &t, Args&& ...args) { // single args std::cout << t << ' '; print_arguments(std::forward(args)...); } diff --git a/tests/helpers/debug.cc b/tests/helpers/debug.cc index f78b64a5..a77ae6ac 100644 --- a/tests/helpers/debug.cc +++ b/tests/helpers/debug.cc @@ -18,3 +18,11 @@ TEST_CASE("Testing get args for debug namespace") { CHECK_NOTHROW(DEBUG::get_args(shortest_path, 0, 2)); } + +TEST_CASE("Testing get args for debug namespace with vectors") { + auto it = [&](int a, int b) -> std::vector { + return {a, b}; + }; + std::vector passed = {2, 4}; + CHECK_NOTHROW(DEBUG::get_args(it, passed)); +}