[lld] BPSectionOrderer: stabilize iteration order with MapVector
[llvm-project.git] / libcxx / test / std / utilities / memory / util.smartptr / util.smartptr.shared / util.smartptr.shared.obs / op_bracket.pass.cpp
blob3a76d31ea5bfa119f66d6ff95fb800a902f4f922
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 // <memory>
11 // UNSUPPORTED: c++03, c++11, c++14
13 // shared_ptr
15 // element_type& operator[](ptrdiff_t i) const;
17 #include "test_macros.h"
19 #include <memory>
20 #include <cassert>
22 int main(int, char**) {
24 const std::shared_ptr<int[8]> p(new int[8]);
26 for (int i = 0; i < 8; ++i)
27 p[i] = i;
28 for (int i = 0; i < 8; ++i)
29 assert(p[i] == i);
32 int* iptr = new int[8];
33 for (int i = 0; i < 8; ++i)
34 iptr[i] = i;
36 const std::shared_ptr<int[8]> p(iptr);
38 for (int i = 0; i < 8; ++i)
39 assert(p[i] == i);
42 const std::shared_ptr<int[]> p(new int[8]);
44 for (int i = 0; i < 8; ++i)
45 p[i] = i;
46 for (int i = 0; i < 8; ++i)
47 assert(p[i] == i);
50 return 0;