]> git.lyx.org Git - lyx.git/blob - boost/boost/optional/optional_io.hpp
Don't need this.
[lyx.git] / boost / boost / optional / optional_io.hpp
1 // Copyright (C) 2005, Fernando Luis Cacciola Carballal.\r
2 //\r
3 // Use, modification, and distribution is subject to the Boost Software\r
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\r
5 // http://www.boost.org/LICENSE_1_0.txt)\r
6 //\r
7 // See http://www.boost.org/lib/optional for documentation.\r
8 //\r
9 // You are welcome to contact the author at:\r
10 //  fernando_cacciola@hotmail.com\r
11 //\r
12 #ifndef BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP\r
13 #define BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP\r
14 \r
15 #if defined __GNUC__\r
16 #  if (__GNUC__ == 2 && __GNUC_MINOR__ <= 97) \r
17 #    define BOOST_OPTIONAL_NO_TEMPLATED_STREAMS\r
18 #  endif\r
19 #endif // __GNUC__\r
20 \r
21 #if defined BOOST_OPTIONAL_NO_TEMPLATED_STREAMS\r
22 #  include <iostream>\r
23 #else \r
24 #  include <istream>\r
25 #  include <ostream>\r
26 #endif  \r
27 \r
28 \r
29 #include "boost/optional/optional.hpp"\r
30 #include "boost/utility/value_init.hpp"\r
31 \r
32 namespace boost\r
33 {\r
34 \r
35 #if defined (BOOST_NO_TEMPLATED_STREAMS)\r
36 template<class T>\r
37 inline std::ostream& operator<<(std::ostream& out, optional<T> const& v)\r
38 #else\r
39 template<class CharType, class CharTrait, class T>\r
40 inline\r
41 std::basic_ostream<CharType, CharTrait>&\r
42 operator<<(std::basic_ostream<CharType, CharTrait>& out, optional<T> const& v)\r
43 #endif\r
44 {\r
45   if ( out.good() )\r
46   {\r
47     if ( !v )\r
48          out << "--" ;\r
49     else out << ' ' << *v ;\r
50   }\r
51 \r
52   return out;\r
53 }\r
54 \r
55 #if defined (BOOST_NO_TEMPLATED_STREAMS)\r
56 template<class T>\r
57 inline std::istream& operator>>(std::istream& in, optional<T>& v)\r
58 #else\r
59 template<class CharType, class CharTrait, class T>\r
60 inline\r
61 std::basic_istream<CharType, CharTrait>&\r
62 operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v)\r
63 #endif\r
64 {\r
65   if ( in.good() )\r
66   {\r
67     int d = in.get();\r
68     if ( d == ' ' )\r
69     {\r
70       T x ;\r
71       in >> x;\r
72       v = x ;\r
73     }\r
74     else\r
75       v = optional<T>() ;\r
76   }\r
77 \r
78   return in;\r
79 }\r
80 \r
81 } // namespace boost\r
82 \r
83 #endif\r
84 \r