I will want to call things like OUT::log("Something happened");
and OUT::log("Code process " + int proc + " occurred.");
but this might have to be changed to something like OUT::log("Code process ", int proc, " occurred.");
What would I put in place of "?" to accomplish this?
I don't want to create 30 different methods for this, ie, not
...I do NOT want to do this...too much chaos.
I understand in C++11, I could do something with int like to_string, and that would make the "string" + int + "string" to work.
Just make all those functions take a single std::string: the content you want to log. Then you should be able to just do OUT::log("text " + std::to_string(stuff) + " other text");
or anything that creates a string.
Stream operators on a wrapper construct to an underlying output stream? Seems like all of the functionality is already there without any extra tedious coding on your part.
However, there's various other libraries (3rd party) that do similar syntax as well which might be more specific to your needs if you really want to avoid C++11.
Having another problem then. I install g++-4.8 and I am still getting
Main_Main.cpp:29:48: error: ‘to_string’ is not a member of ‘std’
Seems like others have had this problem. Any suggestions?
Yes, I am using the right g++ now, still having the problem.
g++ --version
g++ (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.