Debian Codegraph @

libstdc++-v3/testsuite/23_containers/vector/data_access/constexpr.cc

raw
1 // { dg-do compile { target c++20 } }
2
3 #include <vector>
4 #include <testsuite_hooks.h>
5
6 constexpr bool
7 test_data()
8 {
9 std::vector<int> v;
10 VERIFY( v.data() == nullptr );
11 v.reserve(1);
12 VERIFY( v.data() != nullptr );
13 const std::vector<int> v2{1,3,5,9};
14 VERIFY( v.data() != v2.data() );
15 VERIFY( v2.data()[2] == 5 );
16
17 v = v2;
18 VERIFY( v.data() != v2.data() );
19 VERIFY( v.data()[1] == 3 );
20
21 return true;
22 }
23
24 static_assert(test_data());