template<class _Other1,
class _Other2,
class = enable_if_t<is_constructible<_Ty1, _Other1>::value
&& is_constructible<_Ty2, _Other2>::value>,
enable_if_t<is_convertible<_Other1, _Ty1>::value
&& is_convertible<_Other2, _Ty2>::value, int> = 0>
constexpr pair(pair<_Other1, _Other2>&& _Right)
_NOEXCEPT_OP((is_nothrow_constructible<_Ty1, _Other1>::value
&& is_nothrow_constructible<_Ty2, _Other2>::value))
: first(_STD forward<_Other1>(_Right.first)),
second(_STD forward<_Other2>(_Right.second))
{ // construct from moved compatible pair
}
template<class _Other1,
class _Other2,
class = enable_if_t<is_constructible<_Ty1, _Other1>::value
&& is_constructible<_Ty2, _Other2>::value>,
enable_if_t<!is_convertible<_Other1, _Ty1>::value
|| !is_convertible<_Other2, _Ty2>::value, int> = 0>
constexpr explicit pair(pair<_Other1, _Other2>&& _Right)
_NOEXCEPT_OP((is_nothrow_constructible<_Ty1, _Other1>::value
&& is_nothrow_constructible<_Ty2, _Other2>::value))
: first(_STD forward<_Other1>(_Right.first)),
second(_STD forward<_Other2>(_Right.second))
{ // construct from moved compatible pair
}
tiện ích tập tin cho VS 2017 dòng 206, _Other1 và _Other2 là các thông số, đây là std :: cặp 's func xây dựng, và chúng tôi đang sử dụng Other1 và Other2 để khởi "đầu tiên" và "thứ hai",
Tôi nghĩ rằng is_constructible là đủ, tại sao chúng tôi sử dụng is_convertible tại đây?
và nhân tiện, sự khác biệt giữa class = enable_if_t< ... ::value>
và enable_if_t< ... ::value,int> = 0
là gì?Tại sao 'is_convertible' ở đây trong <utility> std :: pair (STL)?
Điều này là để triển khai [\ [pairs.pair \]/12] (http://eel.is/c++draft/pairs.pair#12.sentence-2). – cpplearner