Debian Codegraph @

libstdc++-v3/testsuite/23_containers/default_template_value.cc

raw
1 // { dg-do compile { target c++26 } }
2
3 #include <deque>
4 #include <forward_list>
5 #include <list>
6 #include <string>
7 #include <vector>
8
9 #if !defined(__cpp_lib_algorithm_default_value_type)
10 #error "Feature test macro for default template type for algorithms' values is missing"
11 #elif __cpp_lib_algorithm_default_value_type < 202403L
12 #error "Feature test macro for default template type for algorithms' values is wrong"
13 #endif
14
15 struct S {
16 S(int, double);
17 friend auto operator<=>(const S&, const S&) = default;
18 };
19
20 template<template<typename...> typename Container>
21 void test_erase()
22 {
23 Container<S> c;
24 std::erase(c, {1, 3.14});
25 }
26
27 void
28 test()
29 {
30 test_erase<std::deque>();
31 test_erase<std::forward_list>();
32 test_erase<std::list>();
33 test_erase<std::vector>();
34
35 std::string s;
36 std::erase(s, {'x'});
37
38 std::wstring ws;
39 std::erase(ws, {L'x'});
40 }