Permit output of indeterminate value that isn't converted to a tribool

[SVN r27739]
This commit is contained in:
Douglas Gregor
2005-03-18 20:40:06 +00:00
parent 796f4a5fa8
commit 192433a5e1
2 changed files with 34 additions and 0 deletions

View File

@ -201,6 +201,26 @@ operator<<(std::basic_ostream<CharT, Traits>& out, tribool x)
return out;
}
/**
* \brief Writes the indeterminate tribool value to a stream.
*
* This routine outputs either the integer
* value 2 (if <tt>(out.flags() & std::ios_base::boolalpha) == 0</tt>)
* or the name of the indeterminate value. The name of the
* indeterminate value comes from the indeterminate_name facet (if it
* is defined in the output stream's locale), or from the
* get_default_indeterminate_name function (if it is not defined in the
* locale or if the C++ standard library implementation does not
* support locales).
*
* \returns @p out
*/
template<typename CharT, typename Traits>
inline std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& out,
bool (&)(tribool, detail::indeterminate_t))
{ return out << tribool(indeterminate); }
/**
* \brief Reads a tribool value from a stream.
*

View File

@ -44,6 +44,13 @@ int test_main(int, char*[])
<< std::endl;
BOOST_CHECK(out.str() == "2");
// Output indeterminate (noboolalpha)
out.str(std::string());
out << indeterminate;
std::cout << "Output indeterminate (noboolalpha): " << out.str()
<< std::endl;
BOOST_CHECK(out.str() == "2");
#ifndef BOOST_NO_STD_LOCALE
const std::numpunct<char>& punct =
BOOST_USE_FACET(std::numpunct<char>, out.getloc());
@ -71,6 +78,13 @@ int test_main(int, char*[])
<< std::endl;
BOOST_CHECK(out.str() == "indeterminate");
// Output indeterminate (boolalpha - default name)
out.str(std::string());
out << std::boolalpha << indeterminate;
std::cout << "Output indeterminate (boolalpha - default name): " << out.str()
<< std::endl;
BOOST_CHECK(out.str() == "indeterminate");
# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
// No template constructors, so we can't build the test locale
# else