Skip to content

Instantly share code, notes, and snippets.

@bastih
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bastih/3c786b103bda1974b578 to your computer and use it in GitHub Desktop.
Save bastih/3c786b103bda1974b578 to your computer and use it in GitHub Desktop.
#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