What you are most likely looking for is sprintf which works like printf, but returns a cstring. Thus your code would be
string msg(sprintf( "Selected elements: %d, %d.", i, j ) )
EDIT
Looks like I didn't read my own link. So again you have a three line code. You could always define the following
std::string itostr( int i )
{
    char temp[20];
    std::sprintf( temp, "%d" i);
    std::string out(temp);
    return out;
}
Then you can just use the + operator to concat strings.
string msg("Selected elements: " + itostr(i) + "," + itostr(j) + ".");