// // wrapper_object.hpp // logging // // Created by Sam Jaffe on 4/4/19. // #pragma once #include #include #include "detail/to_string.h" #include "detail/to_json.h" namespace logging { namespace detail { class object { public: template explicit object(T & object); private: friend std::ostream & operator<<(std::ostream & os, object const & obj) { return os << obj.to_string_(obj.ptr_); } template static std::string to_string_impl(void * ptr); private: void * ptr_; std::string (*to_string_)(void*); }; template std::string object::to_string_impl(void * ptr) { return to_string(*static_cast(ptr)); } template object::object(T & object) : ptr_(&object), to_string_(&object::to_string_impl) { } } }