vendredi 23 janvier 2015

Why Isn't to_string Templatized?

I thought that to_string was just templatized and used stringstream under the hood.


Is that not the case?


I want to be able to do this:



class foo{};

ostream& operator<<(ostream& os, const foo& /*bar*/){
os << "foo";
return os;
}

int main() {
foo bar;
string tsTest = to_string(bar);

return 0;
}


But obviously that doesn't work cause to_string isn't templatized.


Aucun commentaire:

Enregistrer un commentaire