template <class T>
void trace(LogBuffer& msgBuffer, T& data)
{
data.trace(msgBuffer);
}
In the above template fuction we are using a generic class T, but when we are compiling on gcc4.1.3 compiler we ar getting the following error.
error:request for member 'trace' in 'data', which is of non-class type 'std::ios_base& ()(std::ios_base&)
The trace function is being called in some other file as shown below
template <class T>
LogBuffer& LogBuffer::operator<<(T & data)
{
trace(*this, data); // trace fuction called here
return *this;
}
We found that the above piece of code compiles fine on older version of gcc compiler like 2.9.
//Trace functions. These are the trace functions called form here we able to call different trace functions of different classes (due to the template deceleration)
//Again these trace functions are at different class of different files.
// here past compiler simply forget the problem of generic type. But GCC 4.1.2 compiler very much specific about this generic types.
// I hope that u can understand with this info..
this is the class which we have
class LogBuffer
{
public:
LogBuffer(LogFactor& logFactor);
~LogBuffer();
uint8_t* GetStart();
size_t GetProcessedSize();
void Flush();
void SetFormat(ios::fmtflags flags, ios::fmtflags mask);
uint8_t GetIndent();
void SetIndent(uint8_t indent);
// Generic flat type
template <class T>
LogBuffer& operator<<(T& data);
// Single element pointer
template <class T>
LogBuffer& operator<<(T* & data);
// Array
template <class T>
LogBuffer& operator<<(const MsgBufferArray<T>& data);
protected:
void SetDefaultFormat();
LoggerFunctor& _functor;
ostringstream _buffer;
uint8_t _indent;
};
and also that some of the definitions at different file are available in the frm of class members.
This template function is unable to resolve the type.
any suggestions....
|