The correct type for Num :
typename iterator_traits<bool*>::difference_type Num=count(&v[0],&v[10],true);
The reason for this is that count always returns:
typename iterator_traits<InputIt>::difference_type
and your InputIt is a pointer to bool:
&v[0]; // is of type bool* &v[10]; // is of type bool*
For me, iterator_traits<bool*>::difference_type is evaluated to long , so you might as well just be using:
long Num=count(&v[0],&v[10],true);
However, I must admit that I did not test it under Visual Studio 2010 Pro explicitly.
source share