Yes and no. It works on any object for which the << operator has been defined using ostream. This or any object for which ostringstream has an overloaded method to process.
Any object in question in a function has the following meanings:
ostream& operator <<(ostream &os, MyObj &obj);
or it falls into one standard overload. Here is a list of overloaded functions found in `ostream ', taken from here :
ostream & Operator <<(bool & val);
ostream & Operator <<(short & val);
ostream & Operator <<(unsigned short & val);
ostream & Operator <<(int & val);
ostream & Operator <<(unsigned int & val);
ostream & Operator <<(long & val);
ostream & Operator <<(unsigned long & val);
ostream & Operator <<(float & val);
ostream & Operator <<(double & val);
ostream & Operator <<(long double & val);
ostream & Operator <<(const void * val);
ostream & Operator <<(streambuf * sb);
ostream & Operator <<(ostream & (* pf) (ostream &));
ostream & Operator <<(ios & (* pf) (ios &));
ostream & Operator <<(ios_base & (* pf) (ios_base &));
*** The following functions are not members, but GLOBAL functions:
ostream & Operator <<(ostream & out, char c);
ostream & Operator <<(ostream & out, signed char c);
ostream & Operator <<(ostream & out, unsigned char c);
ostream & Operator <<(ostream & out, const char * s);
ostream & Operator <<(ostream & out, const signed char * s);
ostream & Operator <<(ostream & out, const unsigned char * s);