1 // { dg-do run { target c++17 } }
2 // { dg-options "-std=gnu++17" }
4 // Copyright (C) 2015-2017 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // 24.8, container access [iterator.container]
25 #include <testsuite_hooks.h>
31 VERIFY(std::data(i
) == i
);
32 VERIFY(std::size(i
) == 42);
33 VERIFY(!std::empty(i
));
39 static constexpr int i
[42]{};
40 constexpr auto d
= std::data(i
);
41 static_assert(d
== i
);
42 constexpr auto s
= std::size(i
);
43 static_assert(s
== 42);
44 constexpr auto e
= std::empty(i
);
51 std::initializer_list
<int> il
{1,2,3};
52 VERIFY(std::data(il
) == il
.begin());
53 VERIFY(std::size(il
) == 3);
54 VERIFY(!std::empty(il
));
55 std::initializer_list
<int> il2
{};
56 VERIFY(std::size(il2
) == 0);
57 VERIFY(std::empty(il2
));
58 static constexpr std::initializer_list
<int> il3
{1,2,3};
59 constexpr auto d
= std::data(il3
);
60 static_assert(d
== il3
.begin());
61 constexpr auto s
= std::size(il3
);
62 static_assert(s
== 3);
63 constexpr auto e
= std::empty(il3
);
70 std::vector
<int> v
{1,2,3};
71 VERIFY(std::data(v
) == v
.data());
72 VERIFY(std::size(v
) == v
.size());
73 VERIFY(!std::empty(v
));
74 std::vector
<int> v2
{};
75 VERIFY(std::size(v2
) == v2
.size());
76 VERIFY(std::empty(v2
));