This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#ifndef NDEBUG | |
#include <iostream> | |
#include <iomanip> | |
#include <vector> | |
template <typename T> | |
void print(T arg, std::string delim = " ") { | |
std::cout << arg << delim; | |
} | |
inline void print(long long arg, std::string delim) { std::cout << std::setw(12) << arg << delim; } | |
inline void print(unsigned long long arg, std::string delim) { std::cout << std::setw(12) << arg << delim; } | |
inline void print(std::uint64_t arg, std::string delim) { std::cout << std::setw(12) << arg << delim; } | |
template <typename T> | |
void print(std::vector<T> arg, std::string delim = " ") { | |
std::cout << "["; | |
for (const auto& val : arg) { | |
print(val, ", "); | |
} | |
std::cout << "]"; | |
} | |
template <typename T> | |
void debug(T arg) { | |
print(arg, ""); | |
std::cout << "\n"; | |
} | |
template <typename T, typename... ARGS> | |
void debug(T arg, ARGS... args) { | |
print(arg, " "); | |
debug(args...); | |
} | |
template <typename T> | |
void debug_delim(std::string delim, T arg) { | |
print(arg, ""); | |
std::cout << "\n"; | |
} | |
template <typename T, typename... ARGS> | |
void debug_delim(std::string delim, T arg, ARGS... args) { | |
print(arg, delim); | |
debug_delim(delim, args...); | |
} | |
#else | |
void debug(...) {}; | |
void debug_delim(...) {}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment