fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. int main() {
  8. const vector<string> v = { "Foo", "Bar", "Bar" };
  9. const_cast< vector<string>& >(v)[2] = "Baz";
  10.  
  11. std::for_each(v.begin(), v.end(), [] (const string &s) {
  12. cout << s << " " << endl;
  13. });
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0s 3064KB
stdin
Standard input is empty
stdout
Foo 
Bar 
Baz