Templates ‘o’ doom

Why, in C++, do templates have to be so damn gnarly?

I am pretty certain that, if I took the time to really learn templates, that I would be able to solve most of my own issues with them. But that initial learning seems to be a learning curve that would make Olympus Mons blush.

I’ve been trying to create a wrapper template that wraps type T with accessors so that it is modification aware (i.e. there’s a timestamp so I can tell when members were modified). The members need to be aware of the parent, though, which I’ve done with references. Unfortunately, the parent class doesn’t know about the children, so I can’t fathom a way to deal with the copy constructor, which means you can’t use it properly with stl containers.

Just getting that far I ran into all kinds of issues with partial template specialization, I guess a chunk of which will be solved by the C++0x extern template feature. I just couldn’t figure out how to declare member-function specializations inside the template class; declaring them extern caused “before instanation” errors, and declaring them after the class lead to duplication errors at link time.

Grr.