Debian Codegraph @

Utilities/std/cm/deque

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