aafulei / color-console

A lightweight header-only C++ library to bring colors to your Windows console with a very-easy-to-use API.
MIT License
258 stars 47 forks source link

I create a new macro that help using function in hue namespace #8

Open felixaszx opened 2 years ago

felixaszx commented 2 years ago

Add a new macro that can support function-like call for hue namespace

#define color(operation,content) operation << content << hue::reset

std::cout<<color(hue::red, "Hello world!"); //(color red)
std::cout<<color(hue::red, "Hello world!") << "just kidding"; //first one color red
std::cout<<color(hue::red, "Hello world!" << "just kidding") ; //2 string color red

all three work, everything outside of the color macro will be reset to original, because this macro call hue::reset after all operation

felixaszx commented 2 years ago

You can just add that macro to the .hpp file