Skip to content

Commit b031e0d

Browse files
committed
better document visit
1 parent e8d8409 commit b031e0d

File tree

1 file changed

+70
-2
lines changed

1 file changed

+70
-2
lines changed

include/boost/json/visit.hpp

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,102 @@ namespace json {
2020

2121
/** Invoke a function object with the contents of a @ref value
2222
23+
Invokes `v` as if by `std::forward<Visitor>(v)( X )`, where `X` is
24+
25+
@li `jv.get_array()` if `jv.is_array()`, or
26+
27+
@li `jv.get_object()` if `jv.is_object()`, or
28+
29+
@li `jv.get_string()` if `jv.is_string()`, or
30+
31+
@li `jv.get_int64()` if `jv.is_int64()`, or
32+
33+
@li `jv.get_uint64()` if `jv.is_uint64()`, or
34+
35+
@li `jv.get_double()` if `jv.is_double()`, or
36+
37+
@li `jv.get_bool()` if `jv.is_bool()`, or
38+
39+
@li reference to an object of type `std::nullptr_t` if `jv.is_null()`.
40+
2341
@return The value returned by Visitor.
2442
2543
@param v The visitation function to invoke
2644
2745
@param jv The value to visit.
2846
*/
29-
/** @{ */
3047
template<class Visitor>
3148
auto
3249
visit(
3350
Visitor&& v,
3451
value& jv) -> decltype(
3552
static_cast<Visitor&&>(v)( std::declval<std::nullptr_t&>() ) );
3653

54+
/** Invoke a function object with the contents of a @ref value
55+
56+
Invokes `v` as if by `std::forward<Visitor>(v)( X )`, where `X` is
57+
58+
@li `jv.get_array()` if `jv.is_array()`, or
59+
60+
@li `jv.get_object()` if `jv.is_object()`, or
61+
62+
@li `jv.get_string()` if `jv.is_string()`, or
63+
64+
@li `jv.get_int64()` if `jv.is_int64()`, or
65+
66+
@li `jv.get_uint64()` if `jv.is_uint64()`, or
67+
68+
@li `jv.get_double()` if `jv.is_double()`, or
69+
70+
@li `jv.get_bool()` if `jv.is_bool()`, or
71+
72+
@li reference to an object of type `const std::nullptr_t` if `jv.is_null()`.
73+
74+
@return The value returned by Visitor.
75+
76+
@param v The visitation function to invoke
77+
78+
@param jv The value to visit.
79+
*/
3780
template<class Visitor>
3881
auto
3982
visit(
4083
Visitor &&v,
4184
value const &jv) -> decltype(
4285
static_cast<Visitor&&>(v)( std::declval<std::nullptr_t const&>() ) );
4386

87+
/** Invoke a function object with the contents of a @ref value
88+
89+
Invokes `v` as if by `std::forward<Visitor>(v)( X )`, where `X` is
90+
91+
@li `std::move( jv.get_array() )` if `jv.is_array()`, or
92+
93+
@li `std::move( jv.get_object() )` if `jv.is_object()`, or
94+
95+
@li `std::move( jv.get_string() )` if `jv.is_string()`, or
96+
97+
@li `std::move( jv.get_int64() )` if `jv.is_int64()`, or
98+
99+
@li `std::move( jv.get_uint64() )` if `jv.is_uint64()`, or
100+
101+
@li `std::move( jv.get_double() )` if `jv.is_double()`, or
102+
103+
@li `std::move( jv.get_bool() )` if `jv.is_bool()`, or
104+
105+
@li `std::nullptr_t()` if `jv.is_null()`.
106+
107+
@return The value returned by Visitor.
108+
109+
@param v The visitation function to invoke
110+
111+
@param jv The value to visit.
112+
*/
44113
template<class Visitor>
45114
auto
46115
visit(
47116
Visitor &&v,
48117
value&& jv) -> decltype(
49118
static_cast<Visitor&&>(v)( std::declval<std::nullptr_t&&>() ) );
50-
/** @} */
51119

52120
} // namespace json
53121
} // namespace boost

0 commit comments

Comments
 (0)