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