View Single Post
Old 2013-04-13, 17:45   #5
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
Rep├║blica de California

2×32×653 Posts
Default

Thanks, Robert, for the very succinct explanation and example. Being able to validate the iterator types at compile time as you demonstrate is very useful, especially in a templatized multi-type context.
Quote:
Originally Posted by Robert Holmes View Post
The reason your the original code fails is deep in the C++ standard's language. In short, when you want the compiler to deduce argument types, those types must not be dependent types. In the above case, the type vector<T>::iterator is dependent on the type of T and will not be deduced.
Now wouldn't it be nice if compilers (or their preprocessors) actually emitted errors to such effect, rather than utterly useless, exceedingly verbose gibberish?

Last fiddled with by ewmayer on 2013-04-14 at 00:51
ewmayer is offline   Reply With Quote