2 // { dg-options "-std=gnu++14" }
4 // Copyright (C) 2015-2016 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.6.5, range access [iterator.range]
25 #include <testsuite_hooks.h>
27 bool test
__attribute__((unused
)) = true;
33 VERIFY(std::cbegin(i
) == i
);
34 VERIFY(std::cend(i
) == i
+1);
35 VERIFY(std::rbegin(i
) == std::reverse_iterator
<int*>(i
+1));
36 VERIFY(std::rend(i
) == std::reverse_iterator
<int*>(i
));
37 VERIFY(std::crbegin(i
) == std::reverse_iterator
<int*>(i
+1));
38 VERIFY(std::crend(i
) == std::reverse_iterator
<int*>(i
));
45 constexpr auto b
__attribute__((unused
)) = std::begin(i
);
46 constexpr auto e
__attribute__((unused
)) = std::end(i
);
47 constexpr auto cb
__attribute__((unused
)) = std::cbegin(i
);
48 constexpr auto ce
__attribute__((unused
)) = std::cend(i
);
54 std::initializer_list
<int> il
{1};
55 VERIFY(std::cbegin(il
) == il
.begin());
56 VERIFY(std::cend(il
) == il
.end());
57 VERIFY(std::rbegin(il
) == std::reverse_iterator
<const int*>(il
.end()));
58 VERIFY(std::rend(il
) == std::reverse_iterator
<const int*>(il
.begin()));
59 VERIFY(std::crbegin(il
) == std::reverse_iterator
<const int*>(il
.end()));
60 VERIFY(std::crend(il
) == std::reverse_iterator
<const int*>(il
.begin()));
66 std::vector
<int> v
{1};
67 VERIFY(std::cbegin(v
) == v
.cbegin());
68 VERIFY(std::cend(v
) == v
.cend());
69 VERIFY(std::rbegin(v
) == v
.rbegin());
70 VERIFY(std::rend(v
) == v
.rend());
71 VERIFY(std::crbegin(v
) == v
.crbegin());
72 VERIFY(std::crend(v
) == v
.crend());