Apparently std::thread just plain doesn't work to pass things by reference, you need to tell it explicitly with std::ref