HerbertKoelman / cpp-atmi

Application-to-Transaction Monitor Interface (ATMI) C++ library
http://herbertkoelman.github.com/cpp-atmi
Other
7 stars 0 forks source link

implement stream operator "auto operator<<(std::ostream& os, const T& t) -> decltype(t.print(os), os) " #111

Open HerbertKoelman opened 7 years ago

HerbertKoelman commented 7 years ago

In C++14 you can use the following template to print any object which has a T::print(std::ostream&)const; member.

template auto operator<<(std::ostream& os, const T& t) -> decltype(t.print(os), os) { t.print(os); return os; }