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<
boost::log::trivial::severity_level
> my_logger_t;
The errors that I see are:
.../boost_1_60_0/build/include/boost/log/utility/formatting_ostream.hpp:799:19:
error: no match for
operator<<
(operand types areboost::log::v2s_mt_posix::basic_formatting_ostream<char>::ostream_type {aka std::basic_ostream<char>}
andconst 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?
Thanks!
Aucun commentaire:
Enregistrer un commentaire