私は地元のstd::vector<std::reference_wrapper<T> >
を持って、今、私はその要素の(すなわちがstd::vector<T>
)を本当のコピーを返すようにしたいです。ループよりも良い方法がありますか?<はstd :: reference_wrapper <T>>はstd ::ベクトルします<T>
例:
std::vector<T> foobar() {
std::vector<std::reference_wrapper<T> > refsToLocals;
/*
do smth with refsToLocals
*/
std::vector<T> copyOfLocals;
for (auto local : refsToLocals)
copyOfLocals.insert_back(local.get());
return copyOfLocals;
}