Can i design my logging-function in a way, that it accepts concatenated strings of the following form using C++?
int i = 1;
customLoggFunction("My Integer i = " << i << ".");
.
customLoggFunction( [...] ){
[...]
std::cout << "Debug Message: " << myLoggMessage << std::endl << std::endl
}
Edit:
Using std::string as the attribute to the function works for the concatenated string, but then a passed non-concatenated string like customLoggFunction("example string") produces a compile-time error saying the function is not applicable for char[]. When i overload the function in the following way...
customLoggFunction(std::string message){...}
customLoggFunction(char message[]){...}
... the concatenated strings seize to work.
I uploaded the code: http://coliru.stacked-crooked.com/a/d64dc90add3e59ed
std::string
? Then you can do e.g.customLoggFunction("My Integer i = " + std::to_string(i) + ".");
– Desiredoperator<<
but it's non-trivial. – Langeloconst char message[]
. – Backstitch