[mlir] Improve error message when number of operands and types differ (#118488)
[llvm-project.git] / libcxx / test / std / iterators / iterator.range / begin-end.initializer_list.pass.cpp
blob2df9283b0576dfd84da2bef0602c200ae49b06f5
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11
11 // <iterator>
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
18 #include <cassert>
19 #include <initializer_list>
20 #include <iterator>
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());
31 const auto& cil = il;
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());
36 return true;
39 int main(int, char**) {
40 test();
41 #if TEST_STD_VER >= 17
42 static_assert(test());
43 #endif
45 return 0;