std::unique_ptr
According to the RAII idiom, a std::unique_ptr manages automatically and exclusively the lifetime of its resource. std::unique_ptr should be your first choice because it does its work without memory or performance overhead.
This author has not written his bio yet.
But we are proud to say that Rainer Grimm contributed 698 entries already.
According to the RAII idiom, a std::unique_ptr manages automatically and exclusively the lifetime of its resource. std::unique_ptr should be your first choice because it does its work without memory or performance overhead.
C++11 offers four different smart pointers. I will have a closer look in this post regarding memory and performance overhead on two of them. My first candidate, std::unique_ptr takes care of the lifetime of one resource exclusively; std::shared_ptr shares the ownership of a resource with another std::shared_ptr. I will state the result of my tests […]
The careful handling of resources – may it be, for example, memory, files, or sockets – is a key concern of programming in C++. This holds, in particular, true for embedded programming, which is often characterized by limited resources. Therefore, I will write a few posts about this challenging and versatile topic.
Plain Old Data (POD) obeys the C standard layout. Therefore, you can directly apply the fast C functions memcopy, memmove, memset, or memcmp.
The hash function maps a potentially infinite number of keys on a finite number of buckets. What is the strategy of the C++ runtime and how can you tailor it to your needs, that is what this article is all about.
The hash function is responsible for the unordered associative containers’ constant access time (best cast). As ever, C++ offers many ways to adjust the behavior of the hash functions. On the one hand, C++ has a lot of different hash functions; on the other hand, you can define your hash function. You can even adjust […]
Before I take a deeper look insight the interface of the hash tables – officially called unordered associative containers – I will first compare the performance of the associative containers. The best candidates are std::unordered_map and the ordered pendant std::map because both are used most frequently.
We missed the hash table in C++ for a long time. They promise to have constant access time. C++11 has hash tables in four variations. The official name is unordered associative containers. Unofficially, they are called dictionaries or just simple associative arrays.
If you look carefully, you see type-traits have a big optimization potential. The type-traits support the first step to analyze the code at the compile-time and, in the second step, to optimize the code based on that analysis. How is that possible? Dependent on the type of variable, a faster variant of an algorithm will […]
constexpr functions are functions that can be executed at compile time. Sounds not so thrilling. But it is. Trust me. You can perform with constexpr functions a lot of calculations at compile time. Therefore, the calculation result is at runtime as a constant in ROM available. In addition, constexpr functions are implicitly inline.