mirror of http://192.168.1.51:8099/lmh188/twain3.0
17 lines
460 B
C++
17 lines
460 B
C++
#pragma once
|
|
#include <algorithm>
|
|
template<typename MapType>
|
|
auto get_map_key_by_value(const MapType& input_map, const decltype(input_map.begin()->second)& mapped_value) -> decltype(input_map.begin()->first)
|
|
{
|
|
auto iter = std::find_if(input_map.begin(), input_map.end(), [mapped_value](const auto& item) {
|
|
return (item.second == mapped_value);
|
|
});
|
|
|
|
if (iter == input_map.end())
|
|
{
|
|
return decltype(input_map.begin()->first)();
|
|
}
|
|
return iter->first;
|
|
}
|
|
|