Overloading insertion operator in Boost.Log (Boost 1.60.0)

I am trying to overload operator<< so that I can log vector<T>s in Boost.Log. I tried overloading the formatting_ostream:

template <typename T>
inline boost::log::formatting_ostream & 
operator<< (boost::log::formatting_ostream & o, const std::vector<T> & v) {
    return o;

This does not compile with Boost 1.60.0

I am using the following logger:

typedef boost::log::sources::severity_logger<
> my_logger_t;

The errors that I see are:


error: no match for operator<< (operand types are boost::log::v2s_mt_posix::basic_formatting_ostream<char>::ostream_type {aka std::basic_ostream<char>} and const std::vector<int>)

strm.stream() << value

As I understand, the overloading doesn't work!! Because the compiler is still calling the pre-defined operator<< which makes the strm.stream() << value call.

Am I doing something wrong? What's the best way to go about this?



This looks like an ADL problem: since operator<< is in neither boost::log nor the std namespaces, it doesn't get picked up during name lookup.

Need Your Help

Laravel 5.2 Redirect admin page after login as admin


Laravel 5.2 has been out for some time now. Yes, it has new auth function which is very good. Specially for beginners.

Is std::ifstream thread-safe & lock-free?

c++ thread-safety ifstream lock-free file-locking

I intend to perform opening for reading a single file from many threads using std::ifstream. My concern is if std::ifstream is thread-safe &amp; lock-free?