Otay, I was brushing up my coding skills by creating a basic, coding 101 list class. At this point it works fine with a generic value, either primitive type or class. If it's a class, all the relational operators need to be overloaded to match the class key.
I suddenly got it into my head that it'd be an excellent idea if there the list node could work with both a generic value and a key. Less overloading, easier sorting, puppies and ice cream...
So I'm thinking of going from:
template <class LISTDATA>
to
template <class LISTKEY, class LISTDATA>
My problem lies with the "could" part of that sentence. What if the main program is declaring a list using only a key variable. I'd like the key/data split to be optional. If the program only calls for an integer, there's no sense in having anything other than a Key value, right?
I tried a small practice run and something like
list <int> l;
doesn't work. It expects two... parameters? in the brackets. So I haven't actually started this project yet.
I've searched the Interwebz without success. I think part of my problem is I don't know what to call what I'm trying to do. Or if it's even a good idea in the first place.