map 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // -*-c++-*-
  2. // vim: set ft=cpp:
  3. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  4. file LICENSE.rst or https://cmake.org/licensing for details. */
  5. #pragma once
  6. #include <map> // IWYU pragma: export
  7. #include <cm/bits/container_helpers.hxx> // IWYU pragma: export
  8. #include <cm/bits/erase_if.hxx>
  9. namespace cm {
  10. // should be updated when C++20 is finalized
  11. #if (__cplusplus > 201703L || \
  12. (defined(_MSVC_LANG) && _MSVC_LANG > 201703)) && \
  13. defined(__cpp_lib_erase_if)
  14. using std::erase_if;
  15. #else
  16. template <typename Key, typename T, typename Compare, typename Allocator,
  17. typename Predicate>
  18. inline void erase_if(std::map<Key, T, Compare, Allocator>& cont,
  19. Predicate pred)
  20. {
  21. internals::erase_if(cont, pred);
  22. }
  23. template <typename Key, typename T, typename Compare, typename Allocator,
  24. typename Predicate>
  25. inline void erase_if(std::multimap<Key, T, Compare, Allocator>& cont,
  26. Predicate pred)
  27. {
  28. internals::erase_if(cont, pred);
  29. }
  30. #endif
  31. } // namespace cm