mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 01:51:38 +08:00
Added example of user defined class with operator<<
This commit is contained in:
parent
297cbc1ffc
commit
386f75200d
@ -88,3 +88,18 @@ int main(int, char* [])
|
||||
std::cout << "Log failed: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Example of user defined class with operator<<
|
||||
//
|
||||
class some_class {};
|
||||
std::ostream& operator<<(std::ostream& os, const some_class& c) { return os << "some_class"; }
|
||||
|
||||
void custom_class_example()
|
||||
{
|
||||
some_class c;
|
||||
spdlog::get("console")->info("custom class with operator<<: {}", c);
|
||||
spdlog::get("console")->info() << "custom class with operator<<: " << c;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user