#ifndef FLUTTER_INAPPWEBVIEW_PLUGIN_LOG_MAP_H_ #define FLUTTER_INAPPWEBVIEW_PLUGIN_LOG_MAP_H_ #include #include #include #include #include namespace flutter_inappwebview_plugin { template struct is_mappish_impl : std::false_type { }; template struct is_mappish_impl()[std::declval()])>> : std::true_type { }; template struct is_mappish : is_mappish_impl::type { }; template static inline bool map_contains(const std::map& map, const K& key) { return map.find(key) != map.end(); } template static inline T map_at_or_null(const std::map& map, const K& key) { auto itr = map.find(key); return itr != map.end() ? itr->second : nullptr; } template static inline auto functional_map(Iterator begin, Iterator end, Func&& func) -> std::vector()))> { using value_type = decltype(func(std::declval())); std::vector out_vector; out_vector.reserve(std::distance(begin, end)); std::transform(begin, end, std::back_inserter(out_vector), std::forward(func)); return out_vector; } template static inline auto functional_map(const T& iterable, Func&& func) -> std::vector()))> { return functional_map(std::begin(iterable), std::end(iterable), std::forward(func)); } template static inline auto functional_map(const std::optional& iterable, Func&& func) -> std::vector()))> { if (!iterable.has_value()) { return {}; } return functional_map(iterable.value(), std::forward(func)); } } #endif //FLUTTER_INAPPWEBVIEW_PLUGIN_LOG_MAP_H_