0
オブジェクトの直列化中にインデントを追加したい。しかしoperator<<
ので、できるだけ2
パラメータが含まれています。オブジェクトのシリアル化中に余分なパラメータを追加する方法はありますか?
struct A {
int member;
};
ostream& operator<<(ostream& str, const A& a)
{
return str;
}
が今私のソリューションは、このようなものです:
struct A {
int m1;
int m2;
};
void print(const A& a, const int indent)
{
cout << string(indent, '\t') << m1 << endl;
cout << string(indent + 1, '\t') << m2 << endl;
}
オブジェクトのシリアル化中に追加のパラメータを追加し、任意のより良い方法はありますか?