gcc/libstdc++-v3/include/experimental/erase_if.h
Edward Smith-Rowland c0b12dad93 Add fundamentals TR container erasure.
2015-04-30  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Add fundamentals TR container erasure.
	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Add new headers.
	* include/experimental/array: New.
	* include/experimental/deque: New.
	* include/experimental/erase_if.tcc: New.
	* include/experimental/forward_list: New.
	* include/experimental/list: New.
	* include/experimental/map: New.
	* include/experimental/set: New.
	* include/experimental/string: New.
	* include/experimental/unordered_map: New.
	* include/experimental/unordered_set: New.
	* include/experimental/vector: New.
	* testsuite/experimental/deque/erasure.cc: New.
	* testsuite/experimental/forward_list/erasure.cc: New.
	* testsuite/experimental/list/erasure.cc: New.
	* testsuite/experimental/map/erasure.cc: New.
	* testsuite/experimental/set/erasure.cc: New.
	* testsuite/experimental/string/erasure.cc: New.
	* testsuite/experimental/unordered_map/erasure.cc: New.
	* testsuite/experimental/unordered_set/erasure.cc: New.
	* testsuite/experimental/vector/erasure.cc: New.

From-SVN: r222630
2015-04-30 14:43:19 +00:00

71 lines
1.9 KiB
C++

// <experimental/erase_if.h> -*- C++ -*-
// Copyright (C) 2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file experimental/erase_if.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly.
*/
#ifndef _GLIBCXX_EXPERIMENTAL_ERASE_IF_H
#define _GLIBCXX_EXPERIMENTAL_ERASE_IF_H 1
#pragma GCC system_header
#if __cplusplus <= 201103L
# include <bits/c++14_warning.h>
#else
namespace std
{
namespace experimental
{
inline namespace fundamentals_v2
{
namespace __detail
{
template<typename _Container, typename _Predicate>
void
__erase_nodes_if(_Container& __cont, _Predicate __pred)
{
for (auto __iter = __cont.begin(), __last = __cont.end();
__iter != __last;)
{
if (__pred(*__iter))
__iter = __cont.erase(__iter);
else
++__iter;
}
}
}
} // inline namespace fundamentals_v2
} // namespace experimental
} // namespace std
#endif // C++14
#endif // _GLIBCXX_EXPERIMENTAL_ERASE_IF_H