C++ version of QSQ