Little Tricks of C/C++
This is a blog recording little tricks I meet or use in C/C++. I will update this blog every time I meet a new trick. (If my memory is good enough to remember this blog😂)
- Use "R" to cancel escape of string.
- Use
gsl::narrow
to cast from one type to another type when there may be a loss in the cast. If the cast does have a loss, for example, cast -5 tounsigned
, an exception will be thrown. If you want to cast it any way, you can usegsl::narrow_cast
to explicitly show the cast.
Â