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 //===----------------------------------------------------------------------===// 8 9 // XFAIL: LIBCXX-AIX-FIXME 10 11 // <string> 12 13 // const_reverse_iterator crbegin() const; // constexpr since C++20 14 15 #include <string> 16 #include <cassert> 17 18 #include "test_macros.h" 19 #include "min_allocator.h" 20 21 template <class S> 22 TEST_CONSTEXPR_CXX20 void 23 test(const S& s) 24 { 25 typename S::const_reverse_iterator cb = s.crbegin(); 26 if (!s.empty()) 27 { 28 assert(*cb == s.back()); 29 } 30 assert(cb == s.rbegin()); 31 } 32 33 TEST_CONSTEXPR_CXX20 bool test() { 34 { 35 typedef std::string S; 36 test(S()); 37 test(S("123")); 38 } 39 #if TEST_STD_VER >= 11 40 { 41 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 42 test(S()); 43 test(S("123")); 44 } 45 #endif 46 47 return true; 48 } 49 50 int main(int, char**) 51 { 52 test(); 53 #if TEST_STD_VER > 17 54 static_assert(test()); 55 #endif 56 57 return 0; 58 } 59