I have the need to have a template class. I want to pass the template a type and then two member variable pointers. The second pointer I want to be defaulted to NULL and thus optional. Is this possible and if so what is the syntax?
What I expected to be the syntax is
template<typename T, int T::*VALUE1, int T::*VALUE2 = NULL>
class Foo { ... }
However when I attempt to instantiate an instance of this class;
Foo<Bar, &Bar::var1> fooBar;
Though instantiating using the following works
Foo<Bar, &Bar::var1, &Bar::var2> fooBar
The error given (from g++ 4.4) is
error: could not convert template argument '0l' to 'int Bar::*'
Please note that I can not use c++11 and thus nullptr