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// <memory>
10
11// UNSUPPORTED: c++03, c++11, c++14
12
13// shared_ptr
14
15// element_type& operator[](ptrdiff_t i) const;
16
17#include "test_macros.h"
18
19#include <memory>
20#include <cassert>
21
22int main(int, char**) {
23 // Check that we get a static assertion when we try to use the bracket
24 // operator on shared_ptr<T> when T is not an array type.
25 const std::shared_ptr<int> p;
26 (void)p[0]; // expected-error@*:* {{std::shared_ptr<T>::operator[] is only valid when T is an array type.}}
27 return 0;
28}
29

source code of libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bracket.verify.cpp