Opened 18 years ago
Closed 18 years ago
#339 closed Bugs (Fixed)
Tribool: strange results on I/O
| Reported by: | ethouris327 | Owned by: | Douglas Gregor |
|---|---|---|---|
| Milestone: | Component: | None | |
| Version: | None | Severity: | |
| Keywords: | Cc: |
Description
Please look at the code below:
#include <iostream>
#include <boost/logic/tribool.hpp>
using namespace std;
using namespace boost::logic;
#define PRINTEXP( exp ) print_exp( #exp, exp )
inline void print_exp( const char* name, tribool expr )
{
cout << name << ": " << boolalpha << expr << endl;
}
int main( int argc, char** argv )
{
cout << true << endl;
cout << false << endl;
cout << indeterminate << endl;
const tribool yes = true;
const tribool no = false;
const tribool maybe = indeterminate;
PRINTEXP( yes );
PRINTEXP( no );
PRINTEXP( maybe );
return 0;
}
According to the documentation, the result should be:
1
0
2
yes: true
no: false
maybe: indeterminate
However the result is:
1
0
1
yes: true
no: false
maybe: false
Of course, there is a warning when compiling:
lite-3bool.cc:20: warning: the address of `bool
boost::logic::indeterminate(boost::logic::tribool,
boost::logic::detail::indeterminate_t)', will always be
`true'
which excuses the "1" for indeterminate, however also
proves that no `ostream& << tribool' is defined (or it's
somehow not seen).
> uname -a
CYGWIN_NT-5.1 hostname 1.5.12(0.116/4/2) 2004-11-
10 08:34 i686 unknown unknown Cygwin
> g++ -v
...
Thread model: posix
gcc version 3.3.3 (cygwin special)
Note:
See TracTickets
for help on using tickets.
