|
Boost Users : |
Subject: [Boost-users] Boost Log: Use of operator<<
From: Florian Lindner (mailinglists_at_[hidden])
Date: 2016-01-21 08:30:57
Hello,
I want to put a custom object called DynamicVector on the BOOG_LOG_SEV
stream.
For that I defined an operator<<
template<typename Vector>
typename std::enable_if<tarch::la::IsVector<Vector>::value,
std::ostream&>::Type operator<< (std::ostream & os, const Vector &
vector);
IsVector<Vector> will be true, since
template<typename Scalar>
struct IsVector<DynamicVector<Scalar> >
{
static const int value = true;
};
The operator itself is working:
// getCoords returns a DynamicVector<double>
std::cout << inMesh->vertices()[j].getCoords();
// compiles just fine.
but
BOOST_LOG_SEV(_log, boost::log::trivial::severity_level::error) <<
inMesh->vertices()[j].getCoords();
gives an compile error:
/usr/include/boost/log/utility/formatting_ostream.hpp:799:19: error:
invalid operands to binary expression ('ostream_type' (aka
'basic_ostream<char_type, traits_type>') and 'const
tarch::la::DynamicVector<double>') strm.stream() << value;
str.stream() seems to be an ostream_type which is an
basic_ostream<char_type, traits_type>.
I wonder why this isn't convertible to std::ostream, like
http://stackoverflow.com/questions/17269499/overloading-operator-for-boost-logging-object
and the comment at
http://www.boost.org/doc/libs/1_54_0/boost/log/utility/formatting_ostream.hpp
suggest.
Any help appreciated!
Thanks,
Florian
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net