Answers for "c++ vector push if not exist"

C++
0

c++ vector push if not exist

std::vector<std::string> name;

if (std::find(name.begin(), name.end(), someName) == name.end()) {
  // someName not in name, add it
  name.push_back(someName);
}
Posted by: Guest on April-26-2021

Browse Popular Code Answers by Language