File indexing completed on 2024-05-12 16:59:21

0001 /*
0002  *   SPDX-FileCopyrightText: 2012-2016 Ivan Cukic <ivan.cukic@kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef UTILS_REMOVE_IF_H
0008 #define UTILS_REMOVE_IF_H
0009 
0010 #include <algorithm>
0011 #include <kactivities-features.h>
0012 
0013 /********************************************************************
0014  *  Syntactic sugar for the erase-remove idiom                      *
0015  ********************************************************************/
0016 
0017 namespace kamd
0018 {
0019 namespace utils
0020 {
0021 template<typename Collection, typename Filter>
0022 __inline void remove_if(Collection &collection, Filter filter)
0023 {
0024     collection.erase(std::remove_if(collection.begin(), collection.end(), filter), collection.end());
0025 }
0026 
0027 } // namespace utils
0028 } // namespace kamd
0029 
0030 #endif // UTILS_REMOVE_IF_H