-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
How we can support for input operator( << ) for custom types.
Something like the below code?
#include <PmLog.h>
using namespace std;
pmlog::PmLog appLog("helloapp");
pmlog::PmLog::Stream pmDebug= appLog.debug() ;
class MyCustomType{
private:
int x;
int y;
float d;
public:
MyCustomType(int x, int y, float d):x(x),y(y),d(d){}
friend pmlog::PmLog::Stream& operator << (pmlog::PmLog::Stream& out, const MyCustomType& obj);
};
pmlog::PmLog::Stream& operator << (pmlog::PmLog::Stream& out, const MyCustomType& obj) {
out << "\n x=" << obj.x;
out << ", y=" << obj.y;
out << ", d=" << obj.d << "\n";
return out;
}
int main() {
pmDebug << "Hello world";
MyCustomType obj1{1,2,3.4f};
pmDebug << obj1;
return 0;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels