27_ref_optional_synopsis.qbk 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. [/
  2. Boost.Optional
  3. Copyright (c) 2003-2007 Fernando Luis Cacciola Carballal
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. ]
  8. [#ref_header_optional_optional_hpp] [section:header_optional_optional Synopsis]
  9. ```// In Header: <`[@boost:/boost/optional/optional.hpp boost/optional/optional.hpp]'''<phrase role="comment">&gt;</phrase>'''``
  10. namespace boost {
  11. class in_place_init_t { /* see below */ } ; ``[link reference_in_place_init __GO_TO__]``
  12. const in_place_init_t in_place_init ( /* see below */ ) ;
  13. class in_place_init_if_t { /*see below*/ } ; ``[link reference_in_place_init_if __GO_TO__]``
  14. const in_place_init_if_t in_place_init_if ( /*see below*/ ) ;
  15. template <class T>
  16. class optional ; ``[link reference_operator_template __GO_TO__]``
  17. template <class T>
  18. class optional<T&> ; ``[link reference_operator_template_spec __GO_TO__]``
  19. template<class T> inline bool operator == ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_equal_optional_optional __GO_TO__]``
  20. template<class T> inline bool operator != ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_not_equal_optional_optional __GO_TO__]``
  21. template<class T> inline bool operator < ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_less_optional_optional __GO_TO__]``
  22. template<class T> inline bool operator > ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_greater_optional_optional __GO_TO__]``
  23. template<class T> inline bool operator <= ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_less_or_equal_optional_optional __GO_TO__]``
  24. template<class T> inline bool operator >= ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_greater_or_equal_optional_optional __GO_TO__]``
  25. template<class T> inline bool operator == ( optional<T> const& x, none_t ) noexcept ; ``[link reference_operator_compare_equal_optional_none __GO_TO__]``
  26. template<class T> inline bool operator != ( optional<T> const& x, none_t ) noexcept ; ``[link reference_operator_compare_not_equal_optional_none __GO_TO__]``
  27. template<class T> inline optional<T> make_optional ( T const& v ) ; ``[link reference_make_optional_value __GO_TO__]``
  28. template<class T> inline optional<std::decay_t<T>> make_optional ( T && v ) ; ``[link reference_make_optional_rvalue __GO_TO__]``
  29. template<class T> inline optional<T> make_optional ( bool condition, T const& v ) ; ``[link reference_make_optional_bool_value __GO_TO__]``
  30. template<class T> inline optional<std::decay_t<T>> make_optional ( bool condition, T && v ) ; ``[link reference_make_optional_bool_rvalue __GO_TO__]``
  31. template<class T> inline auto get_optional_value_or ( optional<T> const& opt, typename optional<T>::reference_const_type def ) -> typename optional<T>::reference_const_type; ``[link reference_free_get_value_or __GO_TO__]``
  32. template<class T> inline auto get_optional_value_or ( optional<T> const& opt, typename optional<T>::reference_type def ) -> typename optional<T>::reference_type ; ``[link reference_free_get_value_or __GO_TO__]``
  33. template<class T> inline T const& get ( optional<T> const& opt ) ; ``[link reference_optional_get __GO_TO__]``
  34. template<class T> inline T& get ( optional<T> & opt ) ; ``[link reference_optional_get __GO_TO__]``
  35. template<class T> inline T const* get ( optional<T> const* opt ) ; ``[link reference_optional_get __GO_TO__]``
  36. template<class T> inline T* get ( optional<T>* opt ) ; ``[link reference_optional_get __GO_TO__]``
  37. template<class T> inline auto get_pointer ( optional<T> const& opt ) -> ``['see below]``; ``[link reference_free_get_pointer __GO_TO__]``
  38. template<class T> inline auto get_pointer ( optional<T> & opt ) -> ``['see below]``; ``[link reference_free_get_pointer __GO_TO__]``
  39. template<class T> inline void swap( optional<T>& x, optional<T>& y ) ; ``[link reference_swap_optional_optional __GO_TO__]``
  40. template<class T> inline void swap( optional<T&>& x, optional<T&>& y ) ; ``[link reference_swap_optional_reference __GO_TO__]``
  41. } // namespace boost
  42. [endsect]
  43. [section:header_optional_in_place_init Initialization tags]
  44. [#reference_in_place_init]
  45. [#reference_in_place_init_if]
  46. namespace boost {
  47. class in_place_init_t { /* see below */ } ;
  48. const in_place_init_t in_place_init ( /* see below */ ) ;
  49. class in_place_init_if_t { /*see below*/ } ;
  50. const in_place_init_if_t in_place_init_if ( /*see below*/ ) ;
  51. }
  52. Classes `in_place_init_t` and `in_place_init_if_t` are empty clsses. Their purpose is to control overload resolution in the initialization of optional objects.
  53. They are empty, trivially copyable classes with disabled default constructor.
  54. [endsect]
  55. [section:header_optional_optional_values Optional Values]
  56. [#reference_operator_template]
  57. template <class T>
  58. class optional
  59. {
  60. public :
  61. typedef T value_type ;
  62. typedef T & reference_type ;
  63. typedef T const& reference_const_type ;
  64. typedef T && rval_reference_type ;
  65. typedef T * pointer_type ;
  66. typedef T const* pointer_const_type ;
  67. optional () noexcept ; ``[link reference_optional_constructor __GO_TO__]``
  68. optional ( none_t ) noexcept ; ``[link reference_optional_constructor_none_t __GO_TO__]``
  69. optional ( T const& v ) ; ``[link reference_optional_constructor_value __GO_TO__]``
  70. optional ( T&& v ) ; ``[link reference_optional_constructor_move_value __GO_TO__]``
  71. optional ( bool condition, T const& v ) ; ``[link reference_optional_constructor_bool_value __GO_TO__]``
  72. optional ( optional const& rhs ) ; ``[link reference_optional_constructor_optional __GO_TO__]``
  73. optional ( optional&& rhs ) noexcept(``['see below]``) ; ``[link reference_optional_move_constructor_optional __GO_TO__]``
  74. template<class U> explicit optional ( optional<U> const& rhs ) ; ``[link reference_optional_constructor_other_optional __GO_TO__]``
  75. template<class U> explicit optional ( optional<U>&& rhs ) ; ``[link reference_optional_move_constructor_other_optional __GO_TO__]``
  76. template<class... Args> explicit optional ( in_place_init_t, Args&&... args ) ; ``[link reference_optional_in_place_init __GO_TO__]``
  77. template<class... Args> explicit optional ( in_place_init_if_t, bool condition, Args&&... args ) ; ``[link reference_optional_in_place_init_if __GO_TO__]``
  78. template<class InPlaceFactory> explicit optional ( InPlaceFactory const& f ) ; ``[link reference_optional_constructor_factory __GO_TO__]``
  79. template<class TypedInPlaceFactory> explicit optional ( TypedInPlaceFactory const& f ) ; ``[link reference_optional_constructor_factory __GO_TO__]``
  80. optional& operator = ( none_t ) noexcept ; ``[link reference_optional_operator_equal_none_t __GO_TO__]``
  81. optional& operator = ( T const& v ) ; ``[link reference_optional_operator_equal_value __GO_TO__]``
  82. optional& operator = ( T&& v ) ; ``[link reference_optional_operator_move_equal_value __GO_TO__]``
  83. optional& operator = ( optional const& rhs ) ; ``[link reference_optional_operator_equal_optional __GO_TO__]``
  84. optional& operator = ( optional&& rhs ) noexcept(``['see below]``) ; ``[link reference_optional_operator_move_equal_optional __GO_TO__]``
  85. template<class U> optional& operator = ( optional<U> const& rhs ) ; ``[link reference_optional_operator_equal_other_optional __GO_TO__]``
  86. template<class U> optional& operator = ( optional<U>&& rhs ) ; ``[link reference_optional_operator_move_equal_other_optional __GO_TO__]``
  87. template<class... Args> void emplace ( Args&&... args ) ; ``[link reference_optional_emplace __GO_TO__]``
  88. template<class InPlaceFactory> optional& operator = ( InPlaceFactory const& f ) ; ``[link reference_optional_operator_equal_factory __GO_TO__]``
  89. template<class TypedInPlaceFactory> optional& operator = ( TypedInPlaceFactory const& f ) ; ``[link reference_optional_operator_equal_factory __GO_TO__]``
  90. T const& get() const ; ``[link reference_optional_get __GO_TO__]``
  91. T& get() ; ``[link reference_optional_get __GO_TO__]``
  92. T const* operator ->() const ; ``[link reference_optional_operator_arrow __GO_TO__]``
  93. T* operator ->() ; ``[link reference_optional_operator_arrow __GO_TO__]``
  94. T const& operator *() const& ; ``[link reference_optional_operator_asterisk __GO_TO__]``
  95. T& operator *() & ; ``[link reference_optional_operator_asterisk __GO_TO__]``
  96. T&& operator *() && ; ``[link reference_optional_operator_asterisk_move __GO_TO__]``
  97. T const& value() const& ; ``[link reference_optional_value __GO_TO__]``
  98. T& value() & ; ``[link reference_optional_value __GO_TO__]``
  99. T&& value() && ; ``[link reference_optional_value_move __GO_TO__]``
  100. template<class U> T value_or( U && v ) const& ; ``[link reference_optional_value_or __GO_TO__]``
  101. template<class U> T value_or( U && v ) && ; ``[link reference_optional_value_or_move __GO_TO__]``
  102. template<class F> T value_or_eval( F f ) const& ; ``[link reference_optional_value_or_call __GO_TO__]``
  103. template<class F> T value_or_eval( F f ) && ; ``[link reference_optional_value_or_call_move __GO_TO__]``
  104. template<class F> auto map( F f ) const& -> ``['see below]``; ``[link reference_optional_map __GO_TO__]``
  105. template<class F> auto map( F f ) & -> ``['see below]``; ``[link reference_optional_map __GO_TO__]``
  106. template<class F> auto map( F f ) && -> ``['see below]``; ``[link reference_optional_map_move __GO_TO__]``
  107. template<class F> auto flat_map( F f ) const& -> ``['see below]``; ``[link reference_optional_flat_map __GO_TO__]``
  108. template<class F> auto flat_map( F f ) & -> ``['see below]``; ``[link reference_optional_flat_map __GO_TO__]``
  109. template<class F> auto flat_map( F f ) && -> ``['see below]``; ``[link reference_optional_flat_map_move __GO_TO__]``
  110. T const* get_ptr() const ; ``[link reference_optional_get_ptr __GO_TO__]``
  111. T* get_ptr() ; ``[link reference_optional_get_ptr __GO_TO__]``
  112. bool has_value() const noexcept ; ``[link reference_optional_operator_bool __GO_TO__]``
  113. explicit operator bool() const noexcept ; ``[link reference_optional_operator_bool __GO_TO__]``
  114. bool operator!() const noexcept ; ``[link reference_optional_operator_not __GO_TO__]``
  115. void reset() noexcept ; ``[link reference_optional_reset __GO_TO__]``
  116. // deprecated methods
  117. // (deprecated)
  118. void reset ( T const& ) ; ``[link reference_optional_reset_value __GO_TO__]``
  119. // (deprecated)
  120. bool is_initialized() const ; ``[link reference_optional_is_initialized __GO_TO__]``
  121. // (deprecated)
  122. T const& get_value_or( T const& default ) const ; ``[link reference_optional_get_value_or_value __GO_TO__]``
  123. };
  124. [endsect]
  125. [section:header_optional_optional_refs Optional References]
  126. [#reference_operator_template_spec]
  127. template <class T>
  128. class optional<T&> // specilization for lvalue references
  129. {
  130. public :
  131. typedef T& value_type;
  132. typedef T& reference_type;
  133. typedef T& reference_const_type; // no const propagation
  134. typedef T& rval_reference_type;
  135. typedef T* pointer_type;
  136. typedef T* pointer_const_type; // no const propagation
  137. optional () noexcept ; ``[link reference_optional_ref_default_ctor __GO_TO__]``
  138. optional ( none_t ) noexcept ; ``[link reference_optional_ref_default_ctor __GO_TO__]``
  139. template<class R> optional(R&& r) noexcept ; ``[link reference_optional_ref_value_ctor __GO_TO__]``
  140. template <class R> optional(bool cond, R&& r) noexcept ; ``[link reference_optional_ref_cond_value_ctor __GO_TO__]``
  141. optional ( optional const& rhs ) noexcept ; ``[link reference_optional_ref_copy_ctor __GO_TO__]``
  142. template<class U> explicit optional ( optional<U&> const& rhs ) noexcept ; ``[link reference_optional_ref_ctor_from_opt_U __GO_TO__]``
  143. optional& operator = ( none_t ) noexcept ; ``[link reference_optional_ref_assign_none_t __GO_TO__]``
  144. optional& operator = ( optional const& rhs ) noexcept; ``[link reference_optional_ref_copy_assign __GO_TO__]``
  145. template<class U> optional& operator = ( optional<U&> const& rhs ) noexcept ; ``[link reference_optional_ref_assign_optional_U __GO_TO__]``
  146. template<class R> optional& operator = (R&& r) noexcept ; ``[link reference_optional_ref_assign_R __GO_TO__]``
  147. template<class R> void emplace ( R&& r ) noexcept ; ``[link reference_optional_ref_emplace_R __GO_TO__]``
  148. T& get() const ; ``[link reference_optional_ref_get __GO_TO__]``
  149. T& operator *() const ; ``[link reference_optional_ref_get __GO_TO__]``
  150. T* operator ->() const ; ``[link reference_optional_ref_arrow __GO_TO__]``
  151. T& value() const& ; ``[link reference_optional_ref_value __GO_TO__]``
  152. template<class R> T& value_or( R && r ) const noexcept ; ``[link reference_optional_ref_value_or __GO_TO__]``
  153. template<class F> T& value_or_eval( F f ) const ; ``[link reference_optional_ref_value_or_eval __GO_TO__]``
  154. template<class F> auto map( F f ) const -> ``['see below]``; ``[link reference_optional_ref_map __GO_TO__]``
  155. template<class F> auto flat_map( F f ) const -> ``['see below]``; ``[link reference_optional_ref_flat_map __GO_TO__]``
  156. T* get_ptr() const noexcept ; ``[link reference_optional_ref_get_ptr __GO_TO__]``
  157. bool has_value() const noexcept ; ``[link reference_optional_ref_operator_bool __GO_TO__]``
  158. explicit operator bool() const noexcept ; ``[link reference_optional_ref_operator_bool __GO_TO__]``
  159. bool operator!() const noexcept ; ``[link reference_optional_ref_operator_not __GO_TO__]``
  160. void reset() noexcept ; ``[link reference_optional_ref_reset __GO_TO__]``
  161. // deprecated methods
  162. // (deprecated)
  163. template<class R> void reset ( R && r ) noexcept ; ``[link reference_optional_ref_reset_value __GO_TO__]``
  164. // (deprecated)
  165. bool is_initialized() const noexcept ; ``[link reference_optional_ref_is_initialized __GO_TO__]``
  166. // (deprecated)
  167. template<class R> T& get_value_or( R && r ) constnoexcept; ``[link reference_optional_ref_get_value_or_value __GO_TO__]``
  168. private:
  169. T* ref; // exposition only
  170. };
  171. [endsect]