Hi,
I have currently
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.
Suppose I have a multi_index_container with ordered unique indexes tagged "by_id" and "by_name".
struct by_id {};
struct by_name {};
using BMI = multi_index::multi_index_container>,
multi_index::ordered_unique>
;
BMI bmi;
auto k = keys(bmi.get());
Based on the documentation, I tried
template< typename Tag,typename Value,typename IndexSpecifierList,typename Allocator >
auto keys(const typename multi_index::index< multi_index::multi_index_container,Tag>::type& m)
{
typedef decltype(c.key_extractor()(*c.begin())) key_type; // A better definition would be welcome
std::vector result;
result.reserve(c.size());
for (const auto &elem : c) {
result.push_back(c.key_extractor()(elem));
}
return result;
}
But the overload resolution fails.
What should be the interface of keys in order to support indices interface of multi_index_container?
Thank you,
Christophe B