1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11
13 // Note that begin and end are tested in libcxx/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
15 // template <class E> constexpr reverse_iterator<const E*> rbegin(initializer_list<E> il); // C++14, constexpr since C++17
16 // template <class E> constexpr reverse_iterator<const E*> rend(initializer_list<E> il); // C++14, constexpr since C++17
19 #include <initializer_list>
22 #include "test_macros.h"
24 TEST_CONSTEXPR_CXX17
bool test() {
25 std::initializer_list
<int> il
= {1, 2, 3};
26 ASSERT_SAME_TYPE(decltype(std::rbegin(il
)), std::reverse_iterator
<const int*>);
27 ASSERT_SAME_TYPE(decltype(std::rend(il
)), std::reverse_iterator
<const int*>);
28 assert(std::rbegin(il
).base() == il
.end());
29 assert(std::rend(il
).base() == il
.begin());
32 ASSERT_SAME_TYPE(decltype(std::rbegin(cil
)), std::reverse_iterator
<const int*>);
33 ASSERT_SAME_TYPE(decltype(std::rend(cil
)), std::reverse_iterator
<const int*>);
34 assert(std::rbegin(cil
).base() == il
.end());
35 assert(std::rend(cil
).base() == il
.begin());
39 int main(int, char**) {
41 #if TEST_STD_VER >= 17
42 static_assert(test());