C++ port of x2