c++ - Copy the address of all elements using std::copy -
i'm trying obtain address of elements of given collection , re-create them std::set. basically, instead of
std::set<t> s1; std::copy(first1, last1, std::inserter(s1, s1.begin()));
i'd insert addresses. like:
std::set<std::add_pointer<t>> s1; std::copy(reference_iterator(first1), reference_iterator(last1), std::inserter(s1, s1.begin()));
here, reference_iterator iterator returning address of element, instead of element, opposed boost indirect_iterator does. there standard way it? many thanks.
use std::transform
re-create modification.
std::transform(first1, last1, std::inserter(s1, s1.begin()), std::addressof<t>);
c++ boost iterator std
No comments:
Post a Comment