1 // Copyright (C) 2005, Fernando Luis Cacciola Carballal.
3 // Use, modification, and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/optional for documentation.
9 // You are welcome to contact the author at:
10 // fernando_cacciola@hotmail.com
12 #ifndef BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP
13 #define BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP
16 # if (__GNUC__ == 2 && __GNUC_MINOR__ <= 97)
17 # define BOOST_OPTIONAL_NO_TEMPLATED_STREAMS
21 #if defined BOOST_OPTIONAL_NO_TEMPLATED_STREAMS
28 #include <boost/none.hpp>
29 #include <boost/assert.hpp>
30 #include "boost/optional/optional.hpp"
31 #include "boost/utility/value_init.hpp"
36 #if defined (BOOST_NO_TEMPLATED_STREAMS)
38 inline std::ostream& operator<<(std::ostream& out, optional<T> const& v)
40 template<class CharType, class CharTrait, class T>
42 std::basic_ostream<CharType, CharTrait>&
43 operator<<(std::basic_ostream<CharType, CharTrait>& out, optional<T> const& v)
50 else out << ' ' << *v ;
56 #if defined (BOOST_NO_TEMPLATED_STREAMS)
58 inline std::istream& operator>>(std::istream& in, optional<T>& v)
60 template<class CharType, class CharTrait, class T>
62 std::basic_istream<CharType, CharTrait>&
63 operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v)
88 in.setstate( std::ios::failbit );