Category : optimization

I am wondering if there is a way to optimize case like following: struct A{ virtual process(int x) const = 0; virtual ~A() = default; }; void useA(A const &a){ for(int i = 0; i < 1000; ++i) a.process(i); } In case like this, if we promise somehow we wont change a vtable, the virtual ..

Read more

An alternative to explicitly deleting constructors and assignment operators to disallow copying/moving/instancing a class is to introduce empty "tag" base classes and inherit them to achieve the same result. Here’s my implementation of such a solution: class Non_copyable { protected: Non_copyable() = default; ~Non_copyable() = default; Non_copyable(const Non_copyable&) = delete; Non_copyable& operator=(const Non_copyable&) = delete; ..

Read more