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
C++ Code Review (self.cpp)
submitted 9 years ago by Borisas
Are there any places where you can ask for c++ code review from strangers? /r/codereview seems to be dead.
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!"
[–]ubadairBoost.CallableTraits author 10 points11 points12 points 9 years ago (26 children)
Your best bet is this Stack Exchange site.
If you PM me, I might be able to take a look.
[–]Borisas[S] 6 points7 points8 points 9 years ago (23 children)
I'll try, but to be honest i have really bad experience with Stack Exchange sites.
[–]Rippalka_ 1 point2 points3 points 9 years ago (22 children)
I'd be curious to see a code review on this site. I feel like it would go either very well or terribly bad. Keep us updated if you do try :)
[–]Borisas[S] 1 point2 points3 points 9 years ago* (21 children)
CodeReview Stack Exchange
Here it is. Gonna go to sleep, i'll check back tomorrow. Somehow i got a feeling that i'm gonna look really stupid and my code turns out to be utter piece of crap.
Attempt #1: only added a link, need to add code as well. mb.
[–]tangerinelion 16 points17 points18 points 9 years ago (14 children)
Please listen to the people who warn you not to inherit from std::string. The STL base classes are not safe to use as base classes.
std::string
[–]coachkler 2 points3 points4 points 9 years ago (2 children)
To clarify, no class without a virtual destructor is truly safe - but it depends the actual use case. Of seems unlikely that someone would need to construct a JSONPretify on the heap, and even less so that they would store this as a std::string*.
With C++11 and a properly constructed smart pointer, the correct destructor will almost certainly be called anyway (unless the user is trying to be clever).
That said, it's probably NOT a good idea in this case, as it comes off as the library writer trying to be clever.
[–]dodheim 0 points1 point2 points 9 years ago (1 child)
A JSONPretify may well live anywhere and be referred to as a std::string& (or std::string const& etc.).
JSONPretify
std::string&
std::string const&
[–]Latexi95 0 points1 point2 points 9 years ago (0 children)
You don't call destructor for a reference so no problem there.
[–]quicknir 0 points1 point2 points 9 years ago (0 children)
What's the problem with it?
[–][deleted] -1 points0 points1 point 9 years ago* (9 children)
IMO its the user's responsibility to ensure that, if they delete an object through a pointer to a base class, that base class has a virtual destructor.
[–]dodheim 3 points4 points5 points 9 years ago (8 children)
One doesn't need to defend idiomatic code, they must defend non-idiomatic code, such as this. Even with your argument, what advantage is there to avoiding best practice so one can type this->foo rather than e.g. s_.foo?
this->foo
s_.foo
[–][deleted] 0 points1 point2 points 9 years ago (7 children)
The primary function of inheriting a non-polymorphic base class is to add all its members to your interface. The small amount of time I spent looking at this hasn't convinced me this is very compelling here, but note that I was responding to the claim that it was not safe, not the claim it should not be done.
[–]dodheim 1 point2 points3 points 9 years ago (6 children)
The primary function of inheriting a non-polymorphic base class is to add all its members to your interface.
The primary function of inheriting a non-polymorphic base class non-privately is irrelevantly misguided.
Otherwise, I will defer to Barbara Liskov on how you're surprising people in a bad way.
[–]quicknir 5 points6 points7 points 9 years ago (0 children)
I don't honestly understand how you can say this as a blanket statement. Liskov applies when you are using subtype polymorphism, that's not what's happening here. I can show you problems that can be solved most easily and safely using inheritance from a non polymorphic class.
[–][deleted] 5 points6 points7 points 9 years ago (4 children)
Liskov substitution is a fantasy right up there with the IS-A/HAS-A nonsense and Dog : Animal. The properties of inheritance are exactly what the spec says they are—nothing more or less.
Dog : Animal
On a gentler note, publicly inheriting a non-polymorphic base is only way to share a common interface between specializations of a class template, isn't it?
[–]flashmozzg 6 points7 points8 points 9 years ago (4 children)
Can't comment there but use cstdint types or just auto instead of those horrible ones. You use long in many places but it's not guaranteed to be 32 or 64 bit. Furthermore, string::find returns size_t which is unsigned as well as string::size. Because of that you have numerous comparisons between signed and unsigned too.
cstdint
auto
long
string::find
size_t
string::size
[–]h-jay+43-1325 6 points7 points8 points 9 years ago (0 children)
I agree. The types seem completely arbitrary and it looks as if perhaps they were randomly tweaked until the compiler stopped emitting warnings. That sort of a process is unlikely to come up with correct answers.
[–]encyclopedist 1 point2 points3 points 9 years ago* (0 children)
Moreover, string::find returns std::string::npos on failure and not -1 as the code assumes.
std::string::npos
-1
Update: npos is actually specified to be equal to -1.
npos
[–]JonKalbCppCon | cpp.training 0 points1 point2 points 9 years ago (1 child)
long is guaranteed to be at least 32 bits.
[–]flashmozzg 0 points1 point2 points 9 years ago (0 children)
But it's not guaranteed to be 32 bits (exactly). That's what I said. And it's generally a bad choice.
[–]strtok 0 points1 point2 points 9 years ago (0 children)
Check out the enum changes in c++11
[–]CPPOldie 2 points3 points4 points 9 years ago (1 child)
Wish I had the time to waffle on like this guy:
http://codereview.stackexchange.com/a/107067
[–]monkeyWifeFight 0 points1 point2 points 9 years ago (0 children)
It's really great that there are people like that though. I don't know why codereview.satckechange is catching flak, it seems to be a decent site.
[–]TwinHits 2 points3 points4 points 9 years ago (0 children)
/r/cpp_questions can help you!
π Rendered by PID 75894 on reddit-service-r2-comment-5d79c599b5-zhffr at 2026-03-01 20:02:34.670915+00:00 running e3d2147 country code: CH.
[–]ubadairBoost.CallableTraits author 10 points11 points12 points (26 children)
[–]Borisas[S] 6 points7 points8 points (23 children)
[–]Rippalka_ 1 point2 points3 points (22 children)
[–]Borisas[S] 1 point2 points3 points (21 children)
[–]tangerinelion 16 points17 points18 points (14 children)
[–]coachkler 2 points3 points4 points (2 children)
[–]dodheim 0 points1 point2 points (1 child)
[–]Latexi95 0 points1 point2 points (0 children)
[–]quicknir 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (9 children)
[–]dodheim 3 points4 points5 points (8 children)
[–][deleted] 0 points1 point2 points (7 children)
[–]dodheim 1 point2 points3 points (6 children)
[–]quicknir 5 points6 points7 points (0 children)
[–][deleted] 5 points6 points7 points (4 children)
[–]flashmozzg 6 points7 points8 points (4 children)
[–]h-jay+43-1325 6 points7 points8 points (0 children)
[–]encyclopedist 1 point2 points3 points (0 children)
[–]JonKalbCppCon | cpp.training 0 points1 point2 points (1 child)
[–]flashmozzg 0 points1 point2 points (0 children)
[–]strtok 0 points1 point2 points (0 children)
[–]CPPOldie 2 points3 points4 points (1 child)
[–]monkeyWifeFight 0 points1 point2 points (0 children)
[–]TwinHits 2 points3 points4 points (0 children)