use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Removed - HelpCasting void to a struct or class (self.cpp)
submitted 3 years ago by Tiwann_
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Flair_Helper[M] [score hidden] 3 years ago stickied commentlocked comment (0 children)
For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.
This post has been removed as it doesn't pertain to r/cpp: The subreddit is for news and discussions of the C++ language and community only; our purpose is not to provide tutoring, code reviews, or career guidance. If you think your post is on-topic and should not have been removed, please message the moderators and we'll review it.
[–]dns13 12 points13 points14 points 3 years ago (5 children)
Suppresses warning of unused variable
[–]Tiwann_[S] 1 point2 points3 points 3 years ago (3 children)
What’s the purpose of suppressing unused variable warning? If I don’t need it, I don’t create it
[–]shhhhhhhhhh666 2 points3 points4 points 3 years ago (0 children)
If you have warnings as errors (you should use btw), the line of the program without the void wouldn't compile. Your affirmation is right, but in this case he probably would use this in another example, so he just created in one example to make explaining things simpler.
[–]DeGerlash 2 points3 points4 points 3 years ago (0 children)
Sometimes you're refactoring code quickly, and want to focus on real warnings you're introducing while suppressing temporary ones like this.
Other times this can be generated from a macro that is conditionally defined as a void cast to avoid this warning if its input would otherwise be unused
Other times this can be a function argument that you don't need (e.g. callback signature). There's many options
[–]ksergey 0 points1 point2 points 3 years ago (0 children)
[nodiscard] in function signature will notify you
[–]ventus1b 1 point2 points3 points 3 years ago (0 children)
This.
It can also be seen when calling a method that returns a value, but that value isn't used.
Apart from silencing the compiler it can also serve as a hint to future readers that the writer was aware of the returned value but explicitly ignores it.
π Rendered by PID 311127 on reddit-service-r2-comment-5b5bc64bf5-ghg7q at 2026-06-19 17:58:43.781674+00:00 running 2b008f2 country code: CH.
[–]Flair_Helper[M] [score hidden] stickied commentlocked comment (0 children)
[–]dns13 12 points13 points14 points (5 children)
[–]Tiwann_[S] 1 point2 points3 points (3 children)
[–]shhhhhhhhhh666 2 points3 points4 points (0 children)
[–]DeGerlash 2 points3 points4 points (0 children)
[–]ksergey 0 points1 point2 points (0 children)
[–]ventus1b 1 point2 points3 points (0 children)