fork download
  1. #include <iostream>
  2.  
  3. #include <vector>
  4.  
  5. #include <string>
  6.  
  7. #include <algorithm>
  8.  
  9.  
  10.  
  11.  
  12.  
  13. int main()
  14.  
  15. {
  16.  
  17. std::vector<std::vector<std::string>> vstring
  18.  
  19. {
  20.  
  21. { "no", "yes" },
  22.  
  23. { "help", "yes" },
  24.  
  25. { "true", "false" }
  26.  
  27. };
  28.  
  29.  
  30.  
  31. const std::string myStr = "help";
  32.  
  33. auto f = std::find_if(vstring.begin(), vstring.end(),
  34.  
  35. [&](std::vector<std::string>const & vs)
  36.  
  37. {
  38.  
  39. return !vs.empty() && myStr == vs[0];
  40.  
  41. });
  42.  
  43.  
  44.  
  45. if (f != vstring.end())
  46.  
  47. {
  48.  
  49. for (auto& s: *f)
  50.  
  51. {
  52.  
  53. std::cout << s << "\n";
  54.  
  55. }
  56.  
  57. }
  58.  
  59. }
  60.  
  61.  
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
help
yes