I'm not gone to talk about popular templates as typedef long long ll;
or typedef vector<int> vi;
. I want to share some of mine templates, which I don't see vary often from other people, but think that this templates are very usefull.
It is often necessary to write something like x = max(x, something)
, and I would like to have a syntax like x max= something
. I use this define for this.
#define cmax(u, v) u = max(u, v)
#define cmin(u, v) u = min(u, v)
Sometimes I forget that the solution in int does not work. And in order not to rewrite it, I will uncomment this define.
// #define int ll
Often the vector reading code looks the same, so I made a template function for this.
template<typename ValueType>
istream& operator>>(istream& in, vector<ValueType>& vect) { fore(vect) in >> val; return in; }
Also, for those who are interested, here is my complete template(someday I'll post it on github with all my DS and other stuffs, someday:D). Maybe you can learn something for yourself or give me some advice.
And there is an ASKII art at the end of my template. But due to the fact that it is too big for the post, it's just screenshot.