+ 1
C++ iterator related question
Is the difference_type and ptrdiff_t in C++ are the same? Assume that x and y are iterator vector<int>::difference_type a = x - y; //a is ptrdiff_t, but the compiler compile with no error And Auto b = x - y; //b is ptrdiff_t If a is ptrdiff_t, why the compiler compile it with the difference_type with no problem? Sorry for my bad english
4 ответов
+ 2
cppreference says this about difference_type: "Signed integer type (usually ptrdiff_t)"
https://en.cppreference.com/w/cpp/container/vector
It is common to typedef all types in your class, so you could change the underlying types if you ever need to. But at the end of the day it's all integers.
+ 2
Yes!
+ 1
Schindlabua means both of them have the same meaning and function right?
+ 1
Schindlabua thx for your help bruh