Я искал. но не могу найти четкий ответ. Поэтому я создал новый вопрос. Коды указаны ниже:
using namespace std;
using pairfortsp = pair<unique_ptr<vector<int>>, unique_ptr<int>>;
int main(int argc, char *argv[]){
unique_ptr<vector<int>> tmpptr1(new vector<int>{1});
unique_ptr<int> tmpptr2(new int(1));
unique_ptr<pairfortsp> tmpptr3(new pairfortsp<tmpptr1,tmpptr2>);
}
Когда я его скомпилировал, я получил две ошибки:
stackover.cpp:25:50: error: invalid operands to binary expression ('pairfortsp *' (aka
'pair<unique_ptr<vector<int> >, unique_ptr<int> > *') and 'unique_ptr<vector<int> >')
unique_ptr<pairfortsp> tmpptr3(new pairfortsp<tmpptr1,tmpptr2>);
..................
stackover.cpp:25:67: error: expected expression
unique_ptr<pairfortsp> tmpptr3(new pairfortsp<tmpptr1,tmpptr2>);
Итак, как правильно создать unique_ptr для пары, подобной той, которую я объявил?
Спасибо.