From a7b282858293528eb46aebffe2d2d049c35a6875 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Wed, 28 Jan 2015 13:39:55 +0200 Subject: [PATCH] Added example of user defined class with operator<< --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index ba8ef1b3..013a0ce7 100644 --- a/README.md +++ b/README.md @@ -136,4 +136,17 @@ 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 << ".."; +} + ```