Template overload of operator ++/--
-
I'd like to do an overlord of operator ++ and -- for my class with templates, like this:
template<typename T> CValueHandler& operator ++ ();
But the thing is, that while it compiles fine, I can't call that overloaded operator.SomeClass myClass; myClass++;
Compiler simply complains it can't find a suitable overload. So, my question is, is it possible to overload ++/-- and use templates too? I can't seem to find a good place to fit in a template type either:SomeClass myClass; myClass<UINT64>++;
Doesn't work either. Using Visual Studio 2005. -
I'd like to do an overlord of operator ++ and -- for my class with templates, like this:
template<typename T> CValueHandler& operator ++ ();
But the thing is, that while it compiles fine, I can't call that overloaded operator.SomeClass myClass; myClass++;
Compiler simply complains it can't find a suitable overload. So, my question is, is it possible to overload ++/-- and use templates too? I can't seem to find a good place to fit in a template type either:SomeClass myClass; myClass<UINT64>++;
Doesn't work either. Using Visual Studio 2005.Yes, you can overload operators in templates. Take a look into the template of Simon Hughes into the articles (keywords: Smart list). He overloaded operator =, +=, [], and I added the operator == for the lists. So it should be no problem to overload the ++ One thing that I had time ago was... I was using the ++ and the program was not running ok. I decided to try += 1, and still failed. The i used
var = var + 1;
and worked ok.Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)