这里代码:
template <typename First, typename Second>
struct pair
{
First key;
Second value;
};
template <typename F, typename S>
using slot= std::unique_ptr<pair<F,S>>;
int main()
{
slot<int, char> abc[100];
abc[2] = std::make_unique<pair<int, char>>(new pair<int, char>{ 5,3 });
for (auto& i : abc)
{
i.reset();
}
auto& a = abc;
};
它给出错误:
Severity Code Description Project File Line Suppression State
Error C2665 'pair<int,char>::pair': no overloaded function could convert all the argument types
我想要插槽容器,在这个示例代码中,我试图理解为什么 make_unique 给出错误... 为什么?以及如何让 unique_ptr 为我的班级工作