Template overload of operator ++/--

This is a discussion on Template overload of operator ++/-- within the C++ Programming forums, part of the General Programming Boards category; I'd like to do an overlord of operator ++ and -- for my class with templates, like this:
Code:
template<typename ...

Template overload of operator ++/--

I'd like to do an overlord of operator ++ and -- for my class with templates, like this:

Code:

template<typename T> CValueHandler& operator ++ ();

But the thing is, that while it compiles fine, I can't call that overloaded operator.

Code:

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:

Prefix returns a reference of itself; the new data is returned.
Postfix returns a copy of itself before the new data is acquired, so it returns old data.
That's how it's supposed to work, from what I understand.

For that matter, I just want to be able to get the code actually compiling since I can't deduce the template T argument.

Let's forget about the operators for now... I need, or want, to know if it's possible to call the overloaded operators when there's no argument that takes T. Which is my main problem; the code won't compile because it can't deduce T.

Let's forget about the operators for now... I need, or want, to know if it's possible to call the overloaded operators when there's no argument that takes T. Which is my main problem; the code won't compile because it can't deduce T.

This statement doesn't make much sense without context.
Show some code.
Kurt

The whole idea was to make a thread-safe class that could store memory kind of like a linked list. Problem was that the memory was stored in raw form and no type information was available, so the operator ++ had to know the type of the data (hence the template) in order to cast the memory to the correct type and increase it.
I'm thinking this is a bit of a problem and there's probably easier ways to do it. For one, storing type information might be done, but it's just that it's so prone to errors since there's so many different types of data that can be stored.

So does the each instance of the list store Values of the same, or can a single list hold multiple types?

If the former, you just need to make your list a template, and take all those templates out of the member functions.

If the latter, you have a more complex problem on your hands. You can't just have you increment and decrement receive a type because the element incremented or decremented to won't necessarily be of the same type. The way to have a list store different types is to use inheritance. Your list would be a list of generic objects. Then have each type inherit from this generic object type. For primitives this requires a warper object that can easily be implemented as a template.

Another option in the later case is to use unions. I'm only mentioning this for completeness. Inheritance is preferred because it is type safe. However, unions are slightly faster because the implementation requires you to figure out which type is stored instead of figuring out on its own.