]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/deque/erasure.cc
libstdc++: Remove dg-options "-std=gnu++20" from 23_containers tests
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / deque / erasure.cc
CommitLineData
b9a2dce8 1// { dg-do run { target c++20 } }
188588e4 2
83ffe9cd 3// Copyright (C) 2018-2023 Free Software Foundation, Inc.
188588e4
ESR
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
19
20#include <deque>
21#include <testsuite_hooks.h>
22
45a8d80f 23#ifndef __cpp_lib_erase_if
0fe9eaaa 24# error "Feature-test macro for erase_if missing in <deque>"
55b00d14 25#elif __cpp_lib_erase_if < 202002
0fe9eaaa 26# error "Feature-test macro for erase_if has wrong value in <deque>"
45a8d80f
JW
27#endif
28
188588e4
ESR
29void
30test01()
31{
32 auto is_odd = [](const int i) { return i % 2 != 0; };
33
34 std::deque<int> d{ 10, 11, 12, 14, 15, 17, 18, 19 };
0b44b4b8 35 auto num = std::erase_if(d, is_odd);
188588e4
ESR
36 std::deque<int> t{ 10, 12, 14, 18 };
37 VERIFY( d == t );
0b44b4b8 38 VERIFY( num == 4 );
188588e4
ESR
39}
40
41void
42test02()
43{
44 std::deque<int> d{ 10, 11, 12, 14, 15, 17, 18, 19 };
0b44b4b8 45 auto num = std::erase(d, 14);
188588e4
ESR
46 std::deque<int> t{ 10, 11, 12, 15, 17, 18, 19 };
47 VERIFY( d == t );
0b44b4b8
ESR
48 VERIFY( num == 1 );
49 num = std::erase(d, 20);
188588e4 50 VERIFY( d == t );
0b44b4b8 51 VERIFY( num == 0 );
188588e4
ESR
52}
53
54int
55main()
56{
57 test01();
58 test02();
59
60 return 0;
61}