/images/p1.jpg

Hi, I'm Tomasz

I'm a professional C++ software engineer with over a decade of hands on development experience with variety of technologies (mostly Linux & embedded systems). This is my blog.

Find me on social media

C++ quick tips: Full template specialisation and one definition rule

Recently I’ve been doing a lot of template meta-programming in C++. As we all know, when writing a class or a function template, the definition must be in the header file. This is because the compiler needs to see the definition of the template in order to instantiate it. There are some exceptions to this rule. The restriction doesn’t apply if you explicitly instantiate the template in the source file (and of course limit the template’s use to the set of types you’ve instantiated it with).

I've tried the "just" task runner. Is it worth it?

I was initially sceptical about just task runner. I wasn’t really convinced that it’s a tool solving a real problem and thought of it more as a gimmick. Finally, I decided to give it a try to form a more informed opinion. Below are some of my observations. It’s just a command executor In essence, that’s everything just is. You create a justfile in which you define tasks. Each task is a set of steps.

9 most common pitfalls every C++ programmer eventually falls into

C++ is an old and complex language with a lot of legacy and dark avenues where problems lurk. Aside of very obscure and arcane problems you might experience when working with C++, there’s a set of very common ones which eventually everyone will come across. So, let’s have some fun and name a few. Most vexing parse Most vexing parse is a declaration ambiguity in the language. What might look like a variable declaration, really is a function declaration.

Does profile guided optimisation work and is it worth the hassle?

Recently, while exploring Python’s code base I stumbled upon these cryptic lines in its build system. I’ve never used profile guided optimisations before so, that led me into a goose chase to learn more about them. This post is about how to use clang to employ these optimisation techniques in practice and how much performance gains can be achieved (if any). What’s profile guided optimisations (PGO)? The main principles behind PGO can be described as:

Profiling and code instrumentation

I’ve recently watched a video from TheCherno about visual benchmarking. In short, he’s using a simple timer class in C++ to collect execution timings of his code and then generate a json file containing profiling data which can be visualised using chrome tracing. He’s using a set of macros to automatically get function names when instrumenting the code. This gave me an idea to actually use gcc instrumentation to inject the timers globally into the entire program and collect the data without having to manually instrument the code.

Modern C sucks and you should definitely NOT embrase it

I’ve recently stumbled upon an article about a “modern” C development environment. It caught my attention; sounds like a good read and potentially a way to learn something new and refresh the good old rusty C skills, so I thought. Unfortunately, it was quite to the contrary, leaving a bitter taste at the end. There’s a lot of stuff I disagree with and frankly some that should be killed with a shovel and buried deep in the ground before it spreads like a disease and make C development even more miserable than it already is.

I've tried CMake with Conan and I really liked it

As it’s probably obvious by now, I’m not a fan of CMake. I don’t like the weird syntax, the verbosity of the language, the flawed concept of multistage build system generation and external dependency management which seems like an after thought. I can’t deny though, that CMake is very popular and has a lot of traction so, it’s the necessary evil until we all, as an industry, decide on some other solution.