Get all subsets from a set

| category: Programming | author: st
Tags: ,

How to extract all combinations (unordered subsets) from a given set in C++?

Let us estimate the count before. Suppose N is the size of a given set, and K is the number of elements in the subset. The count of all combinations (unordered subsets) of size K is

C …

static_cast vs dynamic_cast: undefined behavior

| category: Programming | author: st

Do not use static_cast when you cast from a basic class to a derived one. This may lead to undefined behavior. To handle the polymorphism, a virtual inheritance or a multiple inheritance case always use dynamic_cast instead.

The following short example shows the undefined behavior cases. This works with GCC …

Qt Test limitations and workarounds

| category: Testing | author: st

Pros and cons

Why use Qt Test for unit testing and TDD (test-driven development)?

  • small testing framework (about 6K lines of source code);
  • seamless integration with QtCreator development environment;
  • full support of Qt framework including classes/types and signal/slots;
  • simple to start and use.

However, there are some drawbacks …

C++11 constructors

| category: Programming | author: st
Tags: ,

According to specification, "...constructor is a special non-static member function of a class that is used to initialize objects of its class type". In addition to basic concepts, C++11 introduces move constructors, initializer list type and brace-enclosed lists of comma-separated initializers.

However the impact of introducing new constructors combining …