Travis Vitek wrote:
[...]
If you ask what I prefer, I'm going to tell you I prefer the second option (that is essentially what I wrote originally). But, honestly, for me to care either way, I need to know that there actually a noticeable performance difference between the two techniques.
FYI: I used gcc 4.3 and EDG eccp to measure the difference between the compilation times of each of the two approaches (i.e., using specialization vs using remove_cv). In a program involving 10,000 invocations of is_void on distinct types, the specialization approach was 5 and 10 times faster than the one using remove_cv when using gcc and eccp, respectively. In the same program using only 1000 types, the specialization solution compiled 2 and 3 times faster, respectively. With gcc, the compiler also required about half the amount of system memory to compile the specialization-based solution than the other one. (I didn't measure eccp memory usage). This confirms that template metaprogramming is significantly more costly in terms of system resources than alternative approaches, at least in the gcc and eccp implementations. We should re-run the same tests with other compilers to get a complete picture. Martin