forked from boostorg/logic
Permit output of indeterminate value that isn't converted to a tribool
[SVN r27739]
This commit is contained in:
@ -201,6 +201,26 @@ operator<<(std::basic_ostream<CharT, Traits>& out, tribool x)
|
|||||||
return out;
|
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.
|
* \brief Reads a tribool value from a stream.
|
||||||
*
|
*
|
||||||
|
@ -44,6 +44,13 @@ int test_main(int, char*[])
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
BOOST_CHECK(out.str() == "2");
|
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
|
#ifndef BOOST_NO_STD_LOCALE
|
||||||
const std::numpunct<char>& punct =
|
const std::numpunct<char>& punct =
|
||||||
BOOST_USE_FACET(std::numpunct<char>, out.getloc());
|
BOOST_USE_FACET(std::numpunct<char>, out.getloc());
|
||||||
@ -71,6 +78,13 @@ int test_main(int, char*[])
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
BOOST_CHECK(out.str() == "indeterminate");
|
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)
|
# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
|
||||||
// No template constructors, so we can't build the test locale
|
// No template constructors, so we can't build the test locale
|
||||||
# else
|
# else
|
||||||
|
Reference in New Issue
Block a user