Ok, I figured that there's a problem in partially specializing a function template. A guy on bytes had the same problem, and the answer was to wrap
the function in a struct: a struct inside the function and partially specialize that struct:
http://bytes.com/topic/c/answers/61482-partial-specialization-function-template
But, why does my solution work? And, does it work? I mean, it works ok for me, I tested it, but does it work on every compiler? The link I gave above only mentions 'fully' specialized function templates, so I don't know if I can use those rules to get an answer here...
EDIT: I guess I could too wrap
it in a struct inside to be sure, but why does it work as it is now?
EDIT 2: Ok, I think I got it. The above rules don't have to do with template specialization.
(important note: this use of "specialized" oddly enough has nothing to do with template specializations; it's just an unfortunate colloquialism) |
They are just rules to select which base template fits better to the situation. And I don't do any specialization (if I did, it would be partial and I would end up with an error) as I claim to do (I'll go scratch that). I just offer two base templates and these rules make sure the right one is called in every case. Ok, I think it's pretty clear now.