d: Merge dmd, druntime c7902293d7, phobos 03aeafd20
[gcc.git] / libstdc++-v3 / testsuite / 23_containers / span / nodiscard.cc
blob3bccd1545c3a97d3779e22468ded20c5d2adfa30
1 // { dg-do compile { target c++20 } }
3 #include <span>
5 void
6 test_observers(std::span<int> s)
8 s.size(); // { dg-warning "ignoring return value" }
9 s.size_bytes(); // { dg-warning "ignoring return value" }
10 s.empty(); // { dg-warning "ignoring return value" }
13 void
14 test_element_access(std::span<float> s)
16 s.front(); // { dg-warning "ignoring return value" }
17 s.back(); // { dg-warning "ignoring return value" }
18 s[1]; // { dg-warning "ignoring return value" }
19 s.data(); // { dg-warning "ignoring return value" }
22 struct S { };
24 void
25 test_iterators(std::span<S> s)
27 s.begin(); // { dg-warning "ignoring return value" }
28 s.end(); // { dg-warning "ignoring return value" }
29 s.rbegin(); // { dg-warning "ignoring return value" }
30 s.rend(); // { dg-warning "ignoring return value" }
32 #if __cplusplus > 202002L
33 s.cbegin(); // { dg-warning "ignoring return value" "" { target c++23 } }
34 s.cend(); // { dg-warning "ignoring return value" "" { target c++23 } }
35 s.crbegin(); // { dg-warning "ignoring return value" "" { target c++23 } }
36 s.crend(); // { dg-warning "ignoring return value" "" { target c++23 } }
37 #endif
40 void
41 test_subviews(std::span<long, 20> s)
43 s.first<5>(); // { dg-warning "ignoring return value" }
44 s.first(6); // { dg-warning "ignoring return value" }
45 s.last<7>(); // { dg-warning "ignoring return value" }
46 s.last(8); // { dg-warning "ignoring return value" }
47 s.subspan<1>(); // { dg-warning "ignoring return value" }
48 s.subspan<2, 3>(); // { dg-warning "ignoring return value" }
49 s.subspan(4); // { dg-warning "ignoring return value" }
50 s.subspan(5, 6); // { dg-warning "ignoring return value" }
53 void
54 test_non_members(std::span<S, 20> s)
56 std::as_bytes(s); // { dg-warning "ignoring return value" }
57 std::as_writable_bytes(s); // { dg-warning "ignoring return value" }