1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- [/
- Boost.Optional
- Copyright (c) 2003-2007 Fernando Luis Cacciola Carballal
- Copyright (c) 2015 Andrzej Krzemienski
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
- ]
- [section:io_header Header <boost/optional/optional_io.hpp>]
- [section:io_synop Synopsis]
- ```
- #include <istream>
- #include <ostream>
- #include <boost/optional/optional.hpp>
- namespace boost {
- template <class CharType, class CharTrait, class T>
- std::basic_ostream<CharType, CharTrait>&
- operator<<(std::basic_ostream<CharType, CharTrait>& out, optional<T> const& v); ``[link reference_operator_ostream __GO_TO__]``
- template <class CharType, class CharTrait>
- std::basic_ostream<CharType, CharTrait>&
- operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t const&); ``[link reference_operator_ostream_none __GO_TO__]``
-
- template<class CharType, class CharTrait, class T>
- std::basic_istream<CharType, CharTrait>&
- operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v); ``[link reference_operator_istream __GO_TO__]``
-
- } // namespace boost
- ```
- [endsect]
- [section:io_semantics Detailed semantics]
- [#reference_operator_ostream]
- `template <class CharType, class CharTrait, class T>` [br]
- \u00A0\u00A0\u00A0\u00A0`std::basic_ostream<CharType, CharTrait>&` [br]
- \u00A0\u00A0\u00A0\u00A0`operator<<(std::basic_ostream<CharType, CharTrait>& out, optional<T> const& v);`
- * [*Effect:] Outputs an implementation-defined string. The output contains the information about whether the optional object contains a value or not. If `v` contains a value, the output contains result of calling `out << *v`.
- * [*Returns:] `out`.
- __SPACE__
- [#reference_operator_ostream_none]
- `template <class CharType, class CharTrait, class T>` [br]
- \u00A0\u00A0\u00A0\u00A0`std::basic_ostream<CharType, CharTrait>&` [br]
- \u00A0\u00A0\u00A0\u00A0`operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t);`
- * [*Effect:] Outputs an implementation-defined string.
- * [*Returns:] `out`.
- __SPACE__
- [#reference_operator_istream]
- `template <class CharType, class CharTrait, class T>` [br]
- \u00A0\u00A0\u00A0\u00A0`std::basic_ostream<CharType, CharTrait>&` [br]
- \u00A0\u00A0\u00A0\u00A0`operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v);`
- * [*Requires:] `T` is __SGI_DEFAULT_CONSTRUCTIBLE__ and __MOVE_CONSTRUCTIBLE__.
- * [*Effect:] Reads the value of optional object from `in`. If the string representation indicates that the optional object should contain a value, `v` contains a value and its contained value is obtained as if by default-constructing an object `o` of type `T` and then calling `in >> o`; otherwise `v` does not contain a value, and the previously contained value (if any) has been destroyed.
- * [*Returns:] `out`.
- [endsect]
- [endsect]
|