Inspired by std::chrono idea, I wrote a small header-only library using modern C++ for strongly-typed unit metrics, mostly for distance and speed.
using namespace sipp::literals;
auto distance_in_km = 100.0_km;
sipp::Feet distance_in_feet = distance_in_km;
std::cout << "Distance in kilometers: " << distance_in_km.count() << std::endl;
std::cout << "Distance in feet: " << distance_in_feet.count() << std::endl;
auto casted = sipp::distance_cast<sipp::Meters>(5 * distance_in_km);
std::cout << "Multiplied kilometers and cast to meters: " << casted.count() << std::endl;
See more details in README.
A description of how to set up a switchable film on your window (that is, an electric window blinder) with wireless automatic control based on movement sensor and time of the day.
Continue reading “Switchable window”
Most C++ developers have heard about performance penalty of using virtual functions. But is it really so high that you should avoid this useful and sometimes the only possible language feature for a particular case?
First let’s see when this feature is really needed. When you wish to write a testable code, you likely have to deal with some sort of dependency injection.
Let’s say you have some class:
m_dependency1(param1, param2, param3),
m_dependency2(param1, param2, param3),
m_dependency3(param1, param2, param3)
// some other work for dependencies initialization
// lots of different methods
Continue reading “Virtual functions in C++ – thoughts on performance penalty”