Here is my code that I'm getting (Warning C26409 Avoid calling new and delete explicitly, use std::make_unique instead (r.11).) after doing a Visual Studio 2019 Code Analysis:
#include <windows.h>
#include <strsafe.h>
int main()
{
auto *sResult = new WCHAR[256];
StringCchPrintfW(sResult, 256, L"this is a %s", L"test");
delete[] sResult;
}
I was under the assumption to use new/delete instead of calloc/free, but now the compiler is telling me to use std::make_unique. I can't find any examples on how I can change my code to be compliant.
So my questions are:
how do I change my code so it doens't use new/delete
why should I not use new/delte vs std::make_unique?