I've noticed some cases where std::pair will be implicitly converted to a std::pair of a different type without warning, but I can't figure out why. I've had a look through the constructors for std::pair, and can't figure it out. Can somebody explain this to me?
Example:
std::pair<int,int> a = std::pair<int64_t, int64_t>(1,2);
Gives no warnings with clang -Wall -Weverything.
The constructor
template<class U, class V> pair(const pair<U, V>& p);
allows copying from any pairs provided the first element of p
can be converted to first element of pair being constructed, and the same for second elements.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.