diff --git a/include/boost/logic/tribool_io.hpp b/include/boost/logic/tribool_io.hpp index a75146c..19eb944 100644 --- a/include/boost/logic/tribool_io.hpp +++ b/include/boost/logic/tribool_io.hpp @@ -201,6 +201,26 @@ operator<<(std::basic_ostream& out, tribool x) return out; } +/** + * \brief Writes the indeterminate tribool value to a stream. + * + * This routine outputs either the integer + * value 2 (if (out.flags() & std::ios_base::boolalpha) == 0) + * 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 +inline std::basic_ostream& +operator<<(std::basic_ostream& out, + bool (&)(tribool, detail::indeterminate_t)) +{ return out << tribool(indeterminate); } + /** * \brief Reads a tribool value from a stream. * diff --git a/test/tribool_io_test.cpp b/test/tribool_io_test.cpp index 2c059f7..d7254f1 100644 --- a/test/tribool_io_test.cpp +++ b/test/tribool_io_test.cpp @@ -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& punct = BOOST_USE_FACET(std::numpunct, 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