I've got an interesting issue trying to make an ofstream container class. For the moment, I'm trying to just pass through the << operator to the underlying ofstream object, as such
But this causes problems when using...Code:class CfgFile { ..... template <typename _T> CfgFile& operator<< (_T arg); ..... };
...per the following error.Code:OutputFile << endl;
However, overloading the operator manually, as follows, without templating, eliminates the error.Code:error: no match for ‘operator<<’ in ‘OutputFile << std::endl’
Can anyone who knows templating a little better than I do shed some light?Code:CfgFile& operator<< (bool& arg); CfgFile& operator<< (short& arg); CfgFile& operator<< (unsigned short& arg); CfgFile& operator<< (int& arg); CfgFile& operator<< (unsigned int& arg); CfgFile& operator<< (long& arg); CfgFile& operator<< (unsigned long& arg); CfgFile& operator<< (float& arg); CfgFile& operator<< (double& arg); CfgFile& operator<< (long double& arg); CfgFile& operator<< (const void* arg); CfgFile& operator<< (char arg); CfgFile& operator<< (signed char arg); CfgFile& operator<< (unsigned char arg); CfgFile& operator<< (const char* arg); CfgFile& operator<< (const signed char* arg); CfgFile& operator<< (const unsigned char* arg); CfgFile& operator<< (streambuf* arg); CfgFile& operator<< (ostream& ( *arg )(ostream&)); CfgFile& operator<< (ios& ( *arg )(ios&)); CfgFile& operator<< (ios_base& ( *arg )(ios_base&));
Thanks in advance.
~ Jake