std

C++ memory leak without virtual destructor

In this post I will talk about detecting and debugging memory leaks in a C++11 program, Visual Studio’s built in heap profiler and Intel Parallel Studio 2019. And also the importance of virtual destructors when implementing derived subclasses.

C++ Hello World

This is a C++ introduction tutorial for beginners with an example that will print the text “Hello, World!” written in C++ into the console window.

C++ std::sort predicate with templates

There are a couple of sorting algorithms in C++ from std::sort to lamdbas, each tailored to different use cases. As a programmer, you may or may not want to delve into the depths of sort algorithms. That’s a domain left for experts. Luckily, it’s quite easy to get started with sorting data.

Boost::format string examples

Once boost::format object has been created with a format string and given arguments, there are two ways of getting a std::string (or std::wstring) from it. One is with boost::str() and the other way is with str() member method.

How to stop a std::async task

Sadly, this is only an intrusive way of stopping std::async. For an almost non-intrusive way of stopping a thread, look at boost::thread.

Boost scoped_ptr vs unique_ptr

A unique_ptr is also known as std::unique_ptr. Before C++11 it was boost::unique_ptr, but became a part of STD library in C++11 and is now called std::unique_ptr.

Finding an element in a container (std::vector, std::list, etc.)

There is a time during the usage of a c++ class std::vector, std::list and others, when you need to find an element in the container. For instance, you want to create a collection of numbers (let’s suppose you have stored them in std::vector) and you have some function that checks for the given element in a container. Now you might need to find out whether some number exists in the std::vector class.

Optimize sort algorithm – or how I managed to get a high performance gain

I was recently hired as a C++ guru and performance specialist at a fairly large software consultancy company (1000+ employees). This particular division turned out to be a special division. More on that later. They had some software, which was in dire need of some new set of eyes watching over the code. One should think software developers are quite ubiquitous at a place like that, and they are. However, being mainly a managed shop (C#, Java) the presence of C++ developers is simply stunning (</irony>).