现代C++探秘 评价人数不足
读书笔记 Dealing with Erros in Templates
Soichir
If you run into such a length error message, don't panic! First, look at the error itself and take out what is useful for you:e.g., missing operator>, or something not assignable, or something that is const that should not be. Then find in the call stack the innermost code that is the part of your program, i.e., the location where you call a template function from the standard or a third-party library. Stare or a while at this code and ti's preceding lines becase this is the most likely place where the error occurred (in our experiece). Then ask yourself: Does a type of the functin's template arguments miss an operator or a funciton according to the error message?
Do not get scared to the point that you decide not to use templates for the rest of your life. In most cases, the problem is much simpler than the never-ending error message makes us believe. In our experience, most erros in template functions can be found faster thean run-time errors-with some training.

这段话像励志书里的鸡汤,不过很受用.

0
《现代C++探秘》的全部笔记 1篇
豆瓣
免费下载 iOS / Android 版客户端