---
title: operator[]
description: "访问指定位置的元素。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendtb/ascendtb_01_0023.html
sourcePath: /source/zh/canncommercial/900/API/ascendtb/ascendtb_01_0023.html
indexId: c13ed5eb1e9e0582a48d0b4cc581a2e41be95c375285d0d27ab09d36e8ba17dc64
---
# operator[]

#### 功能说明

访问指定位置的元素。


#### 定义

```
T &operator[](std::size_t i)
const T &operator[](std::size_t i) const
```


#### 参数列表

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| i | 输入 | 需要返回的是第“i”位元素。 |


#### 返回值说明

| 类型 | 输入/输出 | 说明 |
| --- | --- | --- |
| T& | 输出 | 返回的元素。 |


#### 约束说明

调用函数时，SVector中元素数量为0或者传入的“i”大于等于SVector中元素数量，会抛出越界异常。
