23_ref_optional_io.qbk 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. [/
  2. Boost.Optional
  3. Copyright (c) 2003-2007 Fernando Luis Cacciola Carballal
  4. Copyright (c) 2015 Andrzej Krzemienski
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE_1_0.txt or copy at
  7. http://www.boost.org/LICENSE_1_0.txt)
  8. ]
  9. [section:io_header Header <boost/optional/optional_io.hpp>]
  10. [section:io_synop Synopsis]
  11. ```
  12. #include <istream>
  13. #include <ostream>
  14. #include <boost/optional/optional.hpp>
  15. namespace boost {
  16. template <class CharType, class CharTrait, class T>
  17. std::basic_ostream<CharType, CharTrait>&
  18. operator<<(std::basic_ostream<CharType, CharTrait>& out, optional<T> const& v); ``[link reference_operator_ostream __GO_TO__]``
  19. template <class CharType, class CharTrait>
  20. std::basic_ostream<CharType, CharTrait>&
  21. operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t const&); ``[link reference_operator_ostream_none __GO_TO__]``
  22. template<class CharType, class CharTrait, class T>
  23. std::basic_istream<CharType, CharTrait>&
  24. operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v); ``[link reference_operator_istream __GO_TO__]``
  25. } // namespace boost
  26. ```
  27. [endsect]
  28. [section:io_semantics Detailed semantics]
  29. [#reference_operator_ostream]
  30. `template <class CharType, class CharTrait, class T>` [br]
  31. \u00A0\u00A0\u00A0\u00A0`std::basic_ostream<CharType, CharTrait>&` [br]
  32. \u00A0\u00A0\u00A0\u00A0`operator<<(std::basic_ostream<CharType, CharTrait>& out, optional<T> const& v);`
  33. * [*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`.
  34. * [*Returns:] `out`.
  35. __SPACE__
  36. [#reference_operator_ostream_none]
  37. `template <class CharType, class CharTrait, class T>` [br]
  38. \u00A0\u00A0\u00A0\u00A0`std::basic_ostream<CharType, CharTrait>&` [br]
  39. \u00A0\u00A0\u00A0\u00A0`operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t);`
  40. * [*Effect:] Outputs an implementation-defined string.
  41. * [*Returns:] `out`.
  42. __SPACE__
  43. [#reference_operator_istream]
  44. `template <class CharType, class CharTrait, class T>` [br]
  45. \u00A0\u00A0\u00A0\u00A0`std::basic_ostream<CharType, CharTrait>&` [br]
  46. \u00A0\u00A0\u00A0\u00A0`operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v);`
  47. * [*Requires:] `T` is __SGI_DEFAULT_CONSTRUCTIBLE__ and __MOVE_CONSTRUCTIBLE__.
  48. * [*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.
  49. * [*Returns:] `out`.
  50. [endsect]
  51. [endsect]