Split string to int vector in C++

As you guys might know, I’m not so fond of C++. The C language is great but the ++ additions are just not my thing. Here’s an example of why: If you want to split a comma separated string into integers in Python, it’s as simple as: 

[int(s) for s in str.split()]

And you’re done! But in C++, you first have to create a stream and them put the string through the stream to tokenize is and then read again from the stream. The semantics are pretty much the same as Python but the syntax is just horrible. Anyway, here’s how you would do it in the cleanest way possible: 

vector<int> split(const string &s, char delimiter) {     
    vector<int> tokens;     
    string token;     
    istringstream tokenStream(s);     
    while (getline(tokenStream, token, delimiter)) {      
        tokens.push_back(stoi(token));     
    }     
    return tokens;  
}

And to call it from wherever you need it, just do this: 

string in = "1,2,4, 5";
vector<int> res = split(in, ',');
cout << res[3] << endl;