From: Gerd von Egidy Date: Fri, 10 Feb 2012 10:38:01 +0000 (+0100) Subject: add ostream handling to Tribool X-Git-Tag: v2.6~21 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=0f9cf43c751f1319ef3b24d7519e30b1bd108396;p=libi2ncommon add ostream handling to Tribool --- diff --git a/src/tribool.hpp b/src/tribool.hpp index a6469ae..1cb722c 100644 --- a/src/tribool.hpp +++ b/src/tribool.hpp @@ -27,6 +27,11 @@ on this file might be covered by the GNU General Public License. * overloading the comparison operators, we rolled our own class. */ +#ifndef __TRIBOOL_HPP +#define __TRIBOOL_HPP + +#include + namespace I2n { @@ -64,3 +69,25 @@ private: }; } + +namespace std +{ + +// allow Tribools to be easily printed to ostreams +template +inline std::basic_ostream& operator<<(std::basic_ostream& os, + const I2n::Tribool& x) +{ + if (x == I2n::Tribool::False) + os << '0'; + else if (x == I2n::Tribool::True) + os << '1'; + else + os << '?'; + + return os; +} + +} + +#endif