C++ implementation can compose queries