August 2012
Intermediate to advanced
976 pages
30h 17m
English
Using an explicit template argument to represent a template function’s return type works well when we want to let the user determine the return type. In other cases, requiring an explicit template argument imposes a burden on the user with no compensating advantage. For example, we might want to write a function that takes a pair of iterators denoting a sequence and returns a reference to an element in the sequence:
template <typename It>??? &fcn(It beg, It end){ // process the range return *beg; // return a reference to an element from the range}
We don’t know the exact type we want ...
Read now
Unlock full access