Added C++ version. First measurements show JS version 4x slower.