20 Nov
2019
20 Nov
'19
2:06 p.m.
On Wed, Nov 20, 2019 at 2:51 PM Christophe B via Boost-users < boost-users@lists.boost.org> wrote:
template
std::vector<Key> keys(const std::map &m) { ... } I'd like to write an overload that works also with the indices interface of multi_index_container.
template
std::vector<Key> keys(const std::map
&m) { ... }
I suspect that you only need to make your template a little more generic, something like (untested): template <typename C> std::vector<typename C::key_type> keys(const C& c) { std::vector<typename C::key_type> result; result.reserve(c.size()); for (const auto& entry : c) { result.emplace_back(entry.first); } return result; }