How do you debug heavily templated code in c++?

You can try using a newer compiler. If you're using Visual C++ 6.0, switch to 9.0 and you'll see a huge jump in the helpfulness of the compiler errors.

Otherwise, my techniques are usually been to test out as small a section of code as possible until I get the errors isolated. This is probably the template system's greatest failing - there is no sensible way of debugging them.

In your own code, make liberal use of compile-time asserts to make usage problems a little easier to diagnose.


For the STL at least there are tools available that will output more human-friendly error messages. See http://www.bdsoft.com/tools/stlfilt.html

For non-STL templates you'll just have to learn what the errors mean. After you've seen them a dozen times it becomes easier to guess what the problem is. If you post them here maybe somebody can help you figure it out.