diff --git a/include/boost/optional/optional_io.hpp b/include/boost/optional/optional_io.hpp index 4c1c610..e7d1a4c 100644 --- a/include/boost/optional/optional_io.hpp +++ b/include/boost/optional/optional_io.hpp @@ -23,6 +23,15 @@ namespace boost { +template +inline +std::basic_ostream& +operator<<(std::basic_ostream& out, none_t const&) +{ + out << "--"; + return out; +} + template inline std::basic_ostream& diff --git a/test/optional_test_io.cpp b/test/optional_test_io.cpp index d4ee207..3ed0511 100644 --- a/test/optional_test_io.cpp +++ b/test/optional_test_io.cpp @@ -75,12 +75,22 @@ void test( T v, T w ) test2( optional () , make_optional(w)); } +void +test() +{ + stringstream s ; + s << boost::none; + BOOST_ASSERT(s.str() == "--"); +} + + int test_main( int, char* [] ) { try { test(1,2); test(string("hello"),string("buffer")); + test(); } catch ( ... ) {