I'm using an example from Stroustrup C++ 4th Ed Page 692. Does anyone know why typename
must come before Iter::value_type
? Specifically in relation to the second mean
function, why is typename
not required for this template function?
I have read through Stroustrup's book sequentially and am in the templates section. I do not recall reading about the reasoning behind this.
Thanks for your guidance!
template<typename Iter>
typename Iter::value_type mean(Iter first, Iter last);
template<typename T>
T mean(T*,T*);
void f(vector<int>& v, int* p, int n)
{
auto x = mean(v.begin(),v.end());
auto y = mean(p,p+n);
}
Aucun commentaire:
Enregistrer un commentaire