13 #ifndef LARCOREALG_COREUTILS_MAKEVALUEINDEX_H
14 #define LARCOREALG_COREUTILS_MAKEVALUEINDEX_H
26 #include <type_traits>
57 template <
typename Coll,
typename Extractor>
60 template <typename Coll>
70 template <
typename Coll,
typename Extractor>
73 using Value_t =
typename Coll::value_type;
75 #if 0 // this is C++17...
76 = std::remove_reference_t<std::invoke_result_t<Extractor, Value_t>>;
77 #else // ... and this is what Clang 5.0 understands:
78 = std::remove_reference_t<decltype(getter(std::declval<Value_t>()))>;
81 using Map_t = std::map<Key_t, std::size_t>;
86 Key_t
const& key = getter(collValue);
87 auto const iKey = index.lower_bound(key);
88 if ((iKey != index.end()) && (iKey->first == key)) {
90 throw std::runtime_error(
95 index.emplace_hint(iKey, key, iValue);
105 #endif // LARCOREALG_COREUTILS_MAKEVALUEINDEX_H
Definition of util::enumerate().
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Transparent functor that returns its argument just as passed.
Functions to help debugging by instrumenting code.
std::string to_string(WindowPattern const &pattern)
decltype(auto) makeValueIndex(Coll const &coll, Extractor getter)
Returns a map of value to index.
Code that might appear as standard C++ in the future.