0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 16:34:13 +01:00

ircd::util: Add pointer transform suite.

This commit is contained in:
Jason Volk 2018-03-03 21:49:27 -08:00
parent 28ab30e3a0
commit a9b87a5c09

View file

@ -441,5 +441,36 @@ is_powerof2(const long long v)
return v && !(v & (v - 1LL));
}
//
// Transform to pointer utils
//
/// Transform input sequence values to pointers in the output sequence
/// using two input iterators [begin, end] and one output iterator [begin]
template<class input_begin,
class input_end,
class output_begin>
auto
pointers(input_begin&& ib,
const input_end &ie,
output_begin&& ob)
{
return std::transform(ib, ie, ob, []
(auto&& value)
{
return std::addressof(value);
});
}
template<class input_container,
class output_container>
auto
pointers(input_container&& ic,
output_container &oc)
{
return pointers(begin(ic), end(ic), begin(oc));
}
} // namespace util
} // namespace ircd