By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,807 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,807 IT Pros & Developers. It's quick & easy.

Choosing between a Null stream and ostringstream

P: 1
#define LOG(level) \
(level > Log::CurrentLevel() ? NullStream(): Log().Get(level))

struct NullStream:std::ostream {
public:
NullStream():std::ios(0), std::ostream(0){}
};

Log().Get() returns a ostringstream.

The following statement statement gives the below compiler error:
LOG(3) << "logging" << endl;


error: operands to ?: have different types ‘NullStream’ and ‘std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >’

How can I rewrite the Macro LOG?


Thanks
Naveen
Aug 28 '10 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
What are you trying to do?

The first hint of trouble is that #define. You use those in C a lot but rarely in C++.
Aug 29 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.