AlgoPlus v0.1.0
Loading...
Searching...
No Matches
debug.h
1#ifndef DEBUG_H
2#define DEBUG_H
3
4#ifdef __cplusplus
5#include <iostream>
6#include <type_traits>
7#include <vector>
8#endif
9
10namespace DEBUG {
11template <typename T> void print_arguments(const T& t) { // single argument
12 std::cout << t << ' ';
13}
14
15template <typename T> void print_arguments(const std::vector<T>& t) { // vectors as arguments
16 for (const T& x : t) {
17 std::cout << x << ' ';
18 }
19}
20
21template <class T, typename... Args>
22void print_arguments(const std::vector<T>& t, Args&&... args) { // multiple args
23 for (const T& x : t) {
24 std::cout << x << ' ';
25 }
26 print_arguments(std::forward<Args>(args)...);
27}
28
29template <typename T, typename... Args>
30void print_arguments(const T& t, Args&&... args) { // single args
31 std::cout << t << ' ';
32 print_arguments(std::forward<Args>(args)...);
33}
34
35template <typename Func, typename... Args> void get_args(Func&& callback, Args&&... args) {
36 std::cout << "\033[33m" << "Arguments: ";
37 print_arguments(args...);
38 std::cout << '\n';
39}
40} // namespace DEBUG
41
42#endif