@
linux40 template <typename T1, typename T2>
struct pair {
//...
template <typename Other1, typename Other2> constexpr
pair (Other1 &&o1, Other2 &&o2 ) noexcept (
noexcept (T1 (std::forward<Other1>(o1 ))) &&
noexcept (T2 (std::forward<Other2>(o2 )))
): first (std::forward<Other1>(o1 )), second (std::forward<Other2>(o2 )) {}
//...
T1 first;
T2 second;
};
int main ()
{
pair<int, double> a (1, 1.2 );
}
我试着这么写可以通过编译,不知道满不满足你的要求,那两个 first 和 second 在 noexcept 里的我改成了 T1 和 T2 。