Manoj Rao bio photo

Manoj Rao

Your Average Common Man

Email Twitter Github

Remember the annoying warnings that you feel helpless about? Well you shouldn’t because C++-11 introduced Attributes which are indicators to the compiler to either disable a warning or to flag a warning.

C++-17 introduced three main Attributes which are helpful.

[[nodiscard]]

As the name suggests, by annotating the code with [[nodiscard]] you are telling the compiler that the values returned should not be discarded. This is usefull when ignoring the returned value can cause errors in the program.

[[maybe_unused]]

In many cases, some of the variables or values allocated may not be used. Example for this are function parameters that are not used, or data members of a structure or a Class that are not used.

[[fallthrough]]

You have a switch statement and certain cases may not have an explicit break statement. In such cases, the compiler usually throws a warning. To avoid these warnings we should explicitly add [[fallthrough]] statements.

Source

C++17 - The Complete Guide


Bring Your Own Cause

If you think any info here has remotely helped you consider dropping a penny for this cause, just click me . You can visit https://www.bbc.com/news/world-asia-india-52672764 Unfortunately, there are plenty of sad things happening all over the world, if you have a different cause or charity you'd rather support please do. And if you did make a donation, please drop a note to me (annotated) or leave a comment here (anonymous is OK!) and I will use that as motivation to write more useful content here.

If you like topics such as this then please consider subscribing to my podcast. I talk to some of the stalwarts in tech and ask them what their favorite productivity hacks are:

Available on iTunes Podcast

Visit Void Star Podcast’s page on iTunes Podcast Portal. Please Click ‘Subscribe’, leave a comment.

Get it iTunes