I know of the WINAPI
OutputDebugString(L"");
How I could go with a function able to receive n
number of parameters which any
data type, and print the value to a debug
?
By debug I mean a window similar of the Visual Studio
Output
.
CodePudding user response:
This can be achieved with a template:
#include <utility>
#include <iomanip>
#include <sstream>
template <typename Arg, typename... Args>
void Print(Arg&& arg, Args&&... args)
{
std::stringstream ss;
ss<< std::forward<Arg>(arg);
using expander = int[];
(void)expander {
0, (void(out << std::forward<Args>(args)), 0)...
};
OutputDebugStringA(ss.str().c_str());
}
int _tmain(int argc, _TCHAR* argv[])
{
Print( 1, "abcde", 2, 3, "foo");
}