std:: 特定の型 (T1) のベクトルから同じ型 (T1) と別の型 (T2) の std::pair のベクトルに要素を移動する最も正確で効率的な方法は何ですか?
つまり、MoveItems() はどのように記述すればよいのでしょうか。
#include <iostream> // For std::string
#include <string> // For std::string
#include <vector> // For std::vector
#include <utility> // For std::pair
using std::vector;
using std::string;
using std::pair;
vector<string> DownloadedItems;
vector<pair<string,bool>> ActiveItems;
vector<string> Download()
{
vector<string> Items {"These","Words","Are","Usually","Downloaded"};
return Items;
}
void MoveItems()
{
for ( size_t i = 0; i < DownloadedItems.size(); ++i )
ActiveItems.push_back( std::pair<string,bool>(DownloadedItems.at(i),true) );
}
int main()
{
DownloadedItems = Download();
MoveItems();
return 0;
}
お時間を割いてご協力いただき、誠にありがとうございました。