One can generally count on Stack Overflow for excellent, high-quality C++ advice. Several C++ experts regularly contribute (I see Howard Hinnant frequently, for example). But Stack Overflow won’t always give you good answers. Here’s a case where a request for a simple solution generates 10+ responses with code ranging from ~10-30 lines – and in one case over 60 lines spread over two files! – that use macros, templates, proxy objects, and in more than a few cases have surprising and likely annoying side effects… for something that could have been solved with a single character. Yes. One… single… character. Continue Reading

A problem I come across rather frequently has to do with the fact that input in C++ requires a pre-existing variable of the correct type, which either has to be uninitialized or initialized to some “safe” value. There’s a third option, though, and it’s the topic of my first Tippet. Continue Reading

One of the things I hope to do from time to time on this blog is to offer short bits of code that solve relatively common programming problems, and that illustrate clever ways to use modern C++. These are combination tips and snippets, so I’ll be calling them “Tippets“.

You can submit Tippets, and if I like them, they will (eventually) be posted on the blog. You will be properly credited, of course.

I should probably qualify my bluster about all the code on this blog being C++14. While it is true that all of the code on this blog, unless otherwise specified, will be C++14, it is not likely that it will be properly displayed that way. I haven’t dug too deeply into it yet, but I don’t think the syntax-highlighting plugin I’m using supports C++14. In fact, I don’t think it even supports C++11. Continue Reading