Код: Выделить всё
no instance of function template "some_template_function" matches the argument list C/C++(304)
template.cpp(10, 14): argument types are: ()
Код: Выделить всё
#include
template T* some_template_function(T *param)
{
return param;
}
int main(int argc, char **argv)
{
int *x = some_template_function(new int()); // does NOT work
int *y = some_template_function(new int()); // works
}
Код: Выделить всё
template T* some_template_function(T *param)
{
return param;
}
int main(int argc, char **argv)
{
int *x = some_template_function(new int()); // works
int *y = some_template_function(new int()); // works
}
Код: Выделить всё
#include
template T* some_template_function(T *param)
{
return param;
}
int main(int argc, char **argv)
{
int *temp = new int();
int *x = some_template_function(temp); // works
int *y = some_template_function(temp); // works
}
p>
Кроме того, компиляция файла работает нормально, независимо от того, какую из трех версий я использую.
Я также пробовал все виды intelliSenseMode< /code> и compilerPath в VSCode, похоже, ничего не помогает.
Подробнее здесь: https://stackoverflow.com/questions/789 ... ult-of-new