
AMDG Eric Niebler wrote:
Cool! I wonder how that's possible. I have it from Walter Bright (Zortech, Symantec, Digital Mars) that instantiating a template is inherently expensive, and certain features of the C++ language (ADL, partial specialization, etc.) force that to be the case. If Clang has found a way to solve these problems, that's good news indeed. I read form the Wikipedia entry that Clang's C++ support is 2-3 years from being usable, though.
It should be possible to reduce the cost by using fancier data structures. With appropriate data structures, you don't necessarily have to look at every specialization or overload to know which is the most specialized. In most cases with class template specialization, there are only a few cases that can lead to ambiguities. Most specializations are disjoint, so it should be possible to prune most of them quickly. (I haven't thought this through fully--it's probably pretty difficult to get right). Also, except for the templates used for the various extension mechanisms, class templates tend to have only a few specializations. In Christ, Steven Watanabe