Anyone who has dealt with both “narrow” and “wide” strings in the same C++ module is inevitably faced with this little annoyance: In MSVC, you might see an error like C2676 (“binary ‘<<‘: ‘std::basic_ostream<char,std::char_traits<char>>’ does not define this operator or…
Testing static_assert (MSBuild)
Now that we’ve gotten a handle on testing static_assert for CMake, let’s turn our focus to MSBuild. We will use a nearly identical project structure as what was established in the CMake stassert sample project but with all the of…
Testing static_assert (CMake)
One of the many innovations in C++11 was static_assert. This allowed, at long last, a custom error message at compile time. Sure, we’ve had the #error directive for a while, but that only works for conditions that one could evaluate…
DI tricks in C++: ref or ptr?
Dependency injection, AKA “DI”, AKA “passing arguments”, is commonly used in modern software design. You’ll see this approach quite often in C# and Java applications, mainly because these languages have specific support for interfaces and interfaces are a big part…
Stay COM: finishing up the tests
In the last post, we began focusing on testability with COM interface stubs. It was a lot of work, and a good reminder of why backfilling test coverage via a test-last approach is not ideal. Still, it shows that through…
Stay COM: stubs and testing
Previously, we built a Windows Task Scheduler sample application using the COM API via WIL. As far as the client code was concerned, COM was a detail encapsulated by the C++ facade we created: Not a COM pointer to be…
Stay COM: C++ and encapsulation
In the previous post, we discussed using WIL to tame COM APIs. At the end, we had translated a Time Trigger sample from the Task Scheduler API from a very C-like structure into something approaching modern C++. Still, that example…
Stay COM: WIL
(For this series, I’ll assume that you know the basics of COM. If you need a refresher, I highly recommend Kenny Kerr‘s excellent Pluralsight course, The Essentials of COM.) Sooner or later, every Windows programmer has to deal with COM,…
Redecorating with C++
The decorator pattern is one of the classics in the Gang of Four Design Patterns book. Let’s explore this pattern first with a C# example. This is just your average decorator, which as the code comments say, employs inheritance and…
Letter Boxed: Rust impl, part 4 (complete solver)
After some incremental progress in our Letter Boxed solver, we’re now ready to complete the app. Our hard-won “expertise” in Rust now makes the last several steps largely mechanical. The first set of changes produces LetterBox and Vertices structs, so…