Is it possible to declare a class with a templatized constructor? I
was sure it was, but GCC is giving me errors when I try to do this.
Most likely user error. Some example code is:
class MessageHeader
{
private:
int m_count;
public:
MessageHeader(int count) : m_count(count) {}
template<typename TMessageHeader(T& iter)
{
m_count = set_m_count_from_iter(iter);
}
int get_count() const { return m_count; }
};
void foo();
{
vector<charbuf;
MessageHeader header ( vec_iter(buf) );
int count = header.get_count(); // Error on this line.
}
The exact error is:
request for memeber 'get_count' in 'header', which is of non-class
type 'MessageHeader ()(vec_iter)'
Clearly MessageHeader is a class type. If I refrain from using a
temporary variable, and instead write:
vector<charbuf;
vec_iter iter(buf);
Messageheader header(iter);
then it appears to work.
Why is this? Thanks