[C++] Start Using Cucucmber Part 2. This Time With CWT-Cucumber
Thomas Thomas

[C++] Start Using Cucucmber Part 2. This Time With CWT-Cucumber

I have implemented a Cucumber interpreter in C++20. CWT-Cucumber: A C++ Cucumber interpreter is my project for this and except for the rules I have implemented all Cucumber features to the best of my knowledge. In addition, there is a Conan recipe to create a Conan package. This means that there is now a native C++ Cucumber interpreter available without third party dependencies.

Read More
[C++] Lets Review my Article on Type Erasure
Thomas Thomas

[C++] Lets Review my Article on Type Erasure

Someone pointed out that my type erasure example in the other article was broken and called a destructor twice. I investigated this and modified the example, adding an emplace method. In the end it still seems understandable to me, so lets check out this C++ Type Erasure.

Read More
Crafting a Cucumber Interpreter in C/C++
Thomas Thomas

Crafting a Cucumber Interpreter in C/C++

I created a C/C++ Cucumber interpreter, based on “Crafting Interpreters” by Robert Nystrom. It compiles a feature file into byte code which is then executed by a vm. The interpreter implementation is C and there are no third party libraries needed to compile and use it. In addition I created C++ bindings to make it easier to use. Check out this article for my initial thoughts and check out the GitHub repository with the project and its examples.

Read More
My Sphinx Best Practice Guide for Multi-version Documentation in Different Languages
Thomas Thomas

My Sphinx Best Practice Guide for Multi-version Documentation in Different Languages

This is my personal best practice and guide so far about Sphinx documentations. We create a Sphinx documentation from scratch, add some C++ and JavaScript source code documentation, include doxygen and finally publish it on GitHub pages. In the first place it looks quite a lot but after working some time with it this is a really good and nice looking way to have a documentation.

Read More
[C++] Exploring the Potential About a std::find Wrapper
Thomas Thomas

[C++] Exploring the Potential About a std::find Wrapper

In my last example i started to create something similar to C++23 std::optional's .andthen(..) / .orelse(..) for std::find / std::find_if. I tried to achieve something similiar and write a bit less code with this. Unfortunately it turned out it does not improve my code. But it wasn’t for nothing, because I got one use case with maps where I could at least use my approach.

Read More
[C++] A find-Function to Append .and_then(..).or_else(..) in C++
Thomas Thomas

[C++] A find-Function to Append .and_then(..).or_else(..) in C++

Finding values in C++ containers can make large if statements or checking iterators often at end(). With C++23's std::optional there are new wrapper functions like .and_then(..). You can pass a lambda and it will only be called if there is a value. I try to do the same with find, which frees me from always checking an iterator.

Read More
[C++] Breaking Dependencies With Templates
Thomas Thomas

[C++] Breaking Dependencies With Templates

In this article we go over an easy example to create a static interface. Instead of using a interface with virtual methods, we use a template. This gives flexibility and creates an easy way to change the interface. It also removes the dynamic polymorphism. For the clients we use template meta programming and concepts to check if the interface signatures are correct.

Read More
[C++] A std::tuple To Concatenate Validation Criteria
Thomas Thomas

[C++] A std::tuple To Concatenate Validation Criteria

I recently had this problem that I need to store multiple validation functions which returned a bool and I didn’t want to use std::vector or any other runtime container. Concatenating if statements weren’t a good solution either. Ultimately I came up with a solution where I used std::tuple in combination with std::apply

Read More
[C++] Rendering An OpenGL Framebuffer Into A Dear ImGui Window
Thomas Thomas

[C++] Rendering An OpenGL Framebuffer Into A Dear ImGui Window

This is a basic example of how to render a triangle into a framebuffer with OpenGL / GLFW and display this in a Dear ImGui window. This is a basic example in C++, which renders a green triangle into a framebuffer and creates a texture of it. Finally this will be displayed in a Dear ImGui window.

Read More
[C++] User-Defined Literals To Handle Units
Thomas Thomas

[C++] User-Defined Literals To Handle Units

Create a good notation to convert units, like seconds or ms. I used C++11 User-Defined Literals and a specific time type to handle my time units. This approach can also be applied to other units, like meters. Now the code appears more clear because I have a specific notation to distinguish times and can also compare my values correctly without casting it on clients side.

Read More
[C++] Use EnTT When You Need An ECS
Thomas Thomas

[C++] Use EnTT When You Need An ECS

EnTT is an open-source, header-only entity component system library for C++. Most likely there aren’t many reasons to an ECS by your own, so don’t waste time on any details and make fast progress by using this third party library. In this article I integrate in my SDL ECS example EnTT and refactor this project.

Read More
[C++] An Entity-Component-System From Scratch
Thomas Thomas

[C++] An Entity-Component-System From Scratch

ECS is the abbreviation for Entity Component System. Here we’ll create an ECS from scratch with a SDL example in C++. We create a window and we’ll be able to render characters to it. By adding components we are also able to move this character arounde by pressing A, S, D and W. So let’s get started with Entity Component Systems with a C++ example.

Read More
[C++] CRTP For Mixin Classes
Thomas Thomas

[C++] CRTP For Mixin Classes

I had an article about CRTP and C++20 concepts for static polymorphic behaviour. This demonstrated that concepts can replace CRTP but this doesn’t mean that we don’t need CRTP anymore. In this article we create a strong type and extend it with different “Skills” by using CRTP.

Read More
[C++] Combine Type Erasure And Strategies
Thomas Thomas

[C++] Combine Type Erasure And Strategies

In this example we combine type erasure with a strategy like pattern. We continue with a character type from my first article about type erasure and we’ll add a rendering method to them without modifying the concrete classes. This increases encapsulation on our example and demonstrates how powerful this combination could be.

Read More
[C++] Use Type Erasure To Get Dynamic Polymorphic Behavior
Thomas Thomas

[C++] Use Type Erasure To Get Dynamic Polymorphic Behavior

This is a simple and short example to understand the idea of type erasure. In this article we create a simple class which can erase your concrete types and illustrates the general behavior and what it requres to have polymorphic behavior at runtime. For a more comprehensive understanding and include tests, I recommend watching Klaus Iglbergers talk about this topic from CppCon 2022.

Read More
[C++] Genetic Algorithm
Thomas Thomas

[C++] Genetic Algorithm

In this article we’ll take a look on a genetic algorithm. We’ll use this algorithm to find a certain string value. We take a look over the theory of this algorithm and then implment this in C++. In the coding example the population and the individual are represented by an own class which we then use to find our target value.

Read More
[Typescript/C++]: Coroutines: What are they and what we have in C++20
Thomas Thomas

[Typescript/C++]: Coroutines: What are they and what we have in C++20

Coroutines are available with C++20. Unfortunately they aren’t ready to use like in other languages. We still need a generator type, which we implement and create a first, fairly simple coroutine. But before we do so, we take a look on Typescript to understand what coroutines are and how they are implemented there.

Read More
Windows Docker Container for MSVC Builds with Conan in Gitlab
Thomas Thomas

Windows Docker Container for MSVC Builds with Conan in Gitlab

Let’s set up a Windows build using Microsoft Visual Studio Compiler and Conan in Gitlab. We’ll use Windows Docker Containers to run our builds with Gitlab Runner. This is a guide to get started with Windows Docker builds with a Gitlab Runner. Ultimately we store all Conan packages directly on the host to reduce the build time.

Read More
[C++] A Boost Asio Server-Client Example
Thomas Thomas

[C++] A Boost Asio Server-Client Example

A simple server-client example in C++ with Boost Asio. Here I create a server which can accept multiple clients. For the demonstration purpose we send a simple string to the server which is then printed to stdout. This is a really simple example but it helps especially when you start with Boost Asio and networking.

Read More
[C++] Static, Dynamic Polymorphism, CRTP and C++20’s Concepts
Thomas Thomas

[C++] Static, Dynamic Polymorphism, CRTP and C++20’s Concepts

C++20 offers really nice features and a very great one is concepts. In this article I compare existing techniques to implement interfaces (dynamic polymorphism, CRTP) to a new approach by using concepts. With concepts we have a lot of advantages and it affects the current way we write code. It’s clearer and it’s better to understand.

Read More