Atomically std::vector::push_back() and return index
I need to create a function which appends a value to a vector and returns the index of the value that was just appended. Example: int append(std::vector<int>& numbers, int number){ int retval = numbers.size(); // what if some other thread calls push_back(number) in between these calls? numbers.push_back(number); return retval; ...