With modern computers, creating a language doesn’t have to be time-consuming. Actually, far less time-consuming than learning a language.
Dependency injection is a software design where a component does not initialise its dependencies, but these dependencies are passed into…
For years I’ve been programming in C++ with the belief that the bodies of template methods had to be in headers. Only recently I learned that splitting template methods between header and source is, in fact, often perfectly fine.
Ever been criticised for using totally working C code in a C++ codebase just because it wasn’t proper C++? Here’s why you shouldn’t have done it.
If you follow these steps, you might learn to write things normally impossible to do in compile time, such as self-registering factory.
C++20 allows writing functions that suspend and can continue at the next line. This has an amazing application at avoiding writing annoying and error-prone state machines. This article showcases how coroutines can clean up a function that would usually need an ugly state machine.
TL;DR On modern 64-bit PC architectures, C++ exceptions only add unreachable code with destructor calls into functions and their effect on performance is below 1%, but such low values are difficult to measure. Handling rare errors with return values requires additional branching that slows down the program in realistic scenarios by about 5% and are also less convenient. If an exception is actually thrown, stack unwinding costs about 2 µs per stack frame.
This is yet another trick to achieve reflection-like functionality before Reflection TS, this time needing only C++11. It’s based on using CRTP to fill the object with carefully chosen garbage before initialisation.
How to write a template function that takes a class and executes type-dependent code on all its member variables, without requiring the class to specifically support it?
Since I bought Oculus Quest, I felt that it lacked a proper Doom-like action shooter. I created a scene in the editor based on what I envisioned, but it was absolutely impossible to run on Oculus Quest. This article describes various tricks I have used to bring it to Quest without too much sacrifice.