错误 C2065:'static_pointer_cast':未声明的标识符 - Visual Studio 2010

error C2065: 'static_pointer_cast' : undeclared identifier - Visual Studio 2010

我正在尝试将 std::shared_ptr 静态转换为其基础 class。鉴于 classes:

class ImportFileSetting {};
class ImportFileSettingSelect:ImportFileSetting {}

我尝试了以下代码:

std::shared_ptr<ImportFileSettingSelect> selectedSheet_ = std::make_shared<ImportFileSettingSelect>();
std::vector<std::shared_ptr<ImportFileSetting>> settings_;
settings_.push_back(static_pointer_cast<ImportFileSetting>(selectedSheet_));

这是我根据cppreference.com找到的。但它无法编译:

5>src\TechAdminServices\database\techCore\processes\ImportDataSourceExcel.cpp(32): error C2065: 'static_pointer_cast' : undeclared identifier
5>src\TechAdminServices\database\techCore\processes\ImportDataSourceExcel.cpp(32): error C2275: 'ImportFileSetting' : illegal use of this type as an expression
5>          d:\techsys\techadmin\techadminservices\src\techadminservices\database\techcore\processes\ImportFileSetting.h(7) : see declaration of 'ImportFileSetting'

我该如何解决这个问题?

您缺少命名空间:

settings_.push_back(std::static_pointer_cast<ImportFileSetting>(selectedSheet_));
//                  ^^^^^