From 1dda726507e329d72afd129041e1289073190e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Wed, 30 Dec 2009 15:37:14 +0000 Subject: [PATCH] use template instead of macro, no template parsing in debug.h git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32676 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/debug.cpp | 47 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/support/debug.cpp b/src/support/debug.cpp index 03464284af..b242df47ce 100644 --- a/src/support/debug.cpp +++ b/src/support/debug.cpp @@ -197,45 +197,46 @@ void LyXErr::endl() // It seems not possible to instantiate operator template out of class body -#define STREAM_OPERATOR(t) \ -{\ - if (l.enabled()){\ - l.stream() << t;\ - if (l.second_used()){\ - l.second() << t;\ - ProgressInterface::instance()->lyxerrFlush();\ - }\ - }\ - return l;\ +template +LyXErr & toStream(LyXErr & l, T t) +{ + if (l.enabled()){ + l.stream() << t; + if (l.second_used()){ + l.second() << t; + ProgressInterface::instance()->lyxerrFlush(); + } + } + return l; } LyXErr & operator<<(LyXErr & l, void const * t) -STREAM_OPERATOR(t) +{ return toStream(l, t); } LyXErr & operator<<(LyXErr & l, char const * t) -STREAM_OPERATOR(t) +{ return toStream(l, t); } LyXErr & operator<<(LyXErr & l, char t) -STREAM_OPERATOR(t) +{ return toStream(l, t); } LyXErr & operator<<(LyXErr & l, int t) -STREAM_OPERATOR(t) +{ return toStream(l, t); } LyXErr & operator<<(LyXErr & l, unsigned int t) -STREAM_OPERATOR(t) +{ return toStream(l, t); } LyXErr & operator<<(LyXErr & l, long t) -STREAM_OPERATOR(t) +{ return toStream(l, t); } LyXErr & operator<<(LyXErr & l, unsigned long t) -STREAM_OPERATOR(t) +{ return toStream(l, t); } LyXErr & operator<<(LyXErr & l, double t) -STREAM_OPERATOR(t) +{ return toStream(l, t); } LyXErr & operator<<(LyXErr & l, string const & t) -STREAM_OPERATOR(t) +{ return toStream(l, t); } LyXErr & operator<<(LyXErr & l, docstring const & t) -STREAM_OPERATOR(to_utf8(t)); +{ return toStream(l, to_utf8(t)); } LyXErr & operator<<(LyXErr & l, FileName const & t) -STREAM_OPERATOR(t) +{ return toStream(l, t); } LyXErr & operator<<(LyXErr & l, ostream &(*t)(ostream &)) -STREAM_OPERATOR(t) +{ return toStream(l, t); } LyXErr & operator<<(LyXErr & l, ios_base &(*t)(ios_base &)) -STREAM_OPERATOR(t) +{ return toStream(l, t); } // The global instance