fur*_*sal 5 c++ templates constructor visual-studio c++14
std::make_shared()用于直接构造对象shared_ptr并调用给定类型的构造函数,它采用该类型构造函数的参数。它如何知道类型构造函数的参数和定义?当使用 templates 和 ... 运算符时,Visual Studio Intellisense 无法显示类型构造函数的定义,而只会显示模板的通用定义,但std::make_shared()可以显示构造函数的精确定义。它是 Visual Studio Intellisense 的一个功能并且特定于标准库函数,还是我在 C++ 实现中无法猜测的东西std::make_shared()?是这样,我该如何重新创建它?
template<typename T, typename... types>
std::shared_ptr<T> my_make_shared(types... args) {
return std::shared_ptr<T>(new T(args...));
}
Run Code Online (Sandbox Code Playgroud)
这是 std::make_shared() std::make_shared() 的智能感知的样子
这是我的示例的样子我的示例的智能感知