11using namespace std::chrono_literals;
34 void SetColor(
int color) {
35 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
36 SetConsoleTextAttribute(hConsole, WORD(color) );
39#elif defined(__linux__) || defined(__APPLE__)
41 #define BLACK "\033[0;30m"
42 #define BBLACK "\033[1;30m"
43 #define RED "\033[0;31m"
44 #define BRED "\033[1;31m"
45 #define GREEN "\033[0;32m"
46 #define BGREEN "\033[1;32m"
47 #define YELLOW "\033[0;33m"
48 #define BYELLOW "\033[1;33m"
49 #define BLUE "\033[0;34m"
50 #define BBLUE "\033[1;34m"
51 #define MAGENTA "\033[0;35m"
52 #define BMAGENTA "\033[1;35m"
53 #define CYAN "\033[0;36m"
54 #define BCYAN "\033[1;36m"
55 #define WHITE "\033[0;37m"
56 #define BWHITE "\033[1;37m"
57 #define DEFAULT "\033[0m"
60 void SetColor(
const std::string& color) { std::cout << color; }
67 explicit scoped_thr(std::thread&& t_): t(std::move(t_)){
69 throw std::logic_error(
"No thread");
71 ~scoped_thr() {t.join(); }
73 scoped_thr(scoped_thr
const&)=
delete;
74 scoped_thr& operator=(scoped_thr
const&)=
delete;
77 void println(
const T& a) { std::cout << a << std::endl; }
79 void print(
const T& a) { std::cout << a; }
81 constexpr void println(
auto const& a) { std::cout << a << std::endl; }
82 constexpr void print(
auto const& a) { std::cout << a; }
86void time_info(
const long long& time, std::ostream& out){
87 out <<
"The time of the CMMTree calculations : " << time <<
" [ µs ] = " << (0.001*(double)time) <<
" [ ms ]\n";
91void time_info(
const std::string& msg,
const unsigned long& time, std::ostream& out){
92 out << msg << time <<
" [ µs ] = " << (0.001*(double)time) <<
" [ ms ]\n";
94class mt_out :
public std::stringstream
100 mt_out(std::ostream &r = std::cout) : out(r)
105 std::lock_guard<std::mutex> mt{
out_mutex};
125 v = std::move(other.v);
130 std::vector<T> &
vec() {
return v;}
131 std::vector<T>
const&
vec()
const {
return v;}
static std::mutex out_mutex
mt_out(std::ostream &r=std::cout)
ptr_vector_guard()=delete
ptr_vector_guard(const ptr_vector_guard &)=delete
ptr_vector_guard(std::vector< T > &&a)
ptr_vector_guard & operator=(ptr_vector_guard< T > &&other) noexcept
ptr_vector_guard & operator=(const ptr_vector_guard &)=delete
ptr_vector_guard(ptr_vector_guard< T > &&other)
std::vector< T > const & vec() const
constexpr void print(auto const &a)
void time_info(const long long &time, std::ostream &out)
constexpr void println(auto const &a)