Dave Theese wrote:
Hello all,
In the code below, why does a syntax error appear at the location commented
"Syntax error!!!"? What language rule is coming into play here?
members need to be initialized in the constructor.
One thing you could use is a helper template class - it will only work
for parameters that can be made template parameters. Here is an example
for a simple one parameter version of the template.
BTW - any critique is welcome on this template. I'm about to "finish it
up" and release the puppy in my GPL'd C++ library.
template < typename w_type, typename w_init_type, w_init_type w_val >
class AT_IType
{
public:
w_type m_value;
inline AT_IType()
: m_value( w_val )
{
}
inline operator w_type & ()
{
return m_value;
}
inline operator const w_type & () const
{
return m_value;
}
inline w_type & operator = ( const w_type & i_value )
{
m_value = i_value;
return m_value;
}
};
#include <vector>
class Foo
{
public:
AT_IType< std::vector<int>, int, 10 > x;
};