---
title: MakeShared
description: "使用std::make_shared创建对象，创建失败时返回空指针。"
url: https://www.hiascend.com/document/detail/zh/Atlas200IDKA2DeveloperKit/latest/Application%20Development%20Guide/msadg/mxvisionug_0287.html
sourcePath: /source/zh/Atlas200IDKA2DeveloperKit/23.0.RC2/Application Development Guide/msadg/mxvisionug_0287.html
indexId: b819b5f154edd6061623b5d665d3197be6042a0ab29879bc40a82f5cca4018d9102
---
# MakeShared

#### 函数功能

使用std::make_shared创建对象，创建失败时返回空指针。


#### 函数原型

```
template<typename T, typename... Args>
static std::shared_ptr<T> MakeShared(Args && ... args);
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| T | 输入 | 对象类名。 |
| args | 输入 | 创建的T对象构造函数参数。 |


#### 返回参数说明

| 数据结构 | 说明 |
| --- | --- |
| APP\_ERROR | 程序执行返回的错误码，请参考APP\_ERROR说明。 |
