I\'d like to wrap std::cout
for formatting, like so:
mycout([what type?] x, [optional args]) {
... // do some formatting on x first
std:
You can use this kind of class:
#include
using namespace std;
class CustomOut
{
public:
template
CustomOut& operator<<(const T& obj)
{
cout << " my-cout " << obj;
return *this;
}
};
int main()
{
CustomOut mycout;
mycout << "test" << 4 << "\n" << 3.4;
}
You'd need more code to use std::endl and other functors, so i've used here simple \n instead.