|
|
|||
File indexing completed on 2025-12-16 09:54:06
0001 // 0002 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) 0003 // 0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying 0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 0006 // 0007 // Official repository: https://github.com/boostorg/json 0008 // 0009 0010 #ifndef BOOST_JSON_VISIT_HPP 0011 #define BOOST_JSON_VISIT_HPP 0012 0013 #include <boost/json/detail/config.hpp> 0014 #include <boost/json/value.hpp> 0015 #include <type_traits> 0016 #include <utility> 0017 0018 namespace boost { 0019 namespace json { 0020 0021 /** Invoke a function object with the contents of a @ref value 0022 0023 Invokes `v` as if by `std::forward<Visitor>(v)( X )`, where `X` is 0024 0025 @li `jv.get_array()` if `jv.is_array()`, or 0026 0027 @li `jv.get_object()` if `jv.is_object()`, or 0028 0029 @li `jv.get_string()` if `jv.is_string()`, or 0030 0031 @li `jv.get_int64()` if `jv.is_int64()`, or 0032 0033 @li `jv.get_uint64()` if `jv.is_uint64()`, or 0034 0035 @li `jv.get_double()` if `jv.is_double()`, or 0036 0037 @li `jv.get_bool()` if `jv.is_bool()`, or 0038 0039 @li reference to an object of type `std::nullptr_t` if `jv.is_null()`. 0040 0041 @return The value returned by Visitor. 0042 0043 @param v The visitation function to invoke 0044 0045 @param jv The value to visit. 0046 */ 0047 template<class Visitor> 0048 auto 0049 visit( 0050 Visitor&& v, 0051 value& jv) -> decltype( 0052 static_cast<Visitor&&>(v)( std::declval<std::nullptr_t&>() ) ); 0053 0054 /** Invoke a function object with the contents of a @ref value 0055 0056 Invokes `v` as if by `std::forward<Visitor>(v)( X )`, where `X` is 0057 0058 @li `jv.get_array()` if `jv.is_array()`, or 0059 0060 @li `jv.get_object()` if `jv.is_object()`, or 0061 0062 @li `jv.get_string()` if `jv.is_string()`, or 0063 0064 @li `jv.get_int64()` if `jv.is_int64()`, or 0065 0066 @li `jv.get_uint64()` if `jv.is_uint64()`, or 0067 0068 @li `jv.get_double()` if `jv.is_double()`, or 0069 0070 @li `jv.get_bool()` if `jv.is_bool()`, or 0071 0072 @li reference to an object of type `const std::nullptr_t` if `jv.is_null()`. 0073 0074 @return The value returned by Visitor. 0075 0076 @param v The visitation function to invoke 0077 0078 @param jv The value to visit. 0079 */ 0080 template<class Visitor> 0081 auto 0082 visit( 0083 Visitor &&v, 0084 value const &jv) -> decltype( 0085 static_cast<Visitor&&>(v)( std::declval<std::nullptr_t const&>() ) ); 0086 0087 /** Invoke a function object with the contents of a @ref value 0088 0089 Invokes `v` as if by `std::forward<Visitor>(v)( X )`, where `X` is 0090 0091 @li `std::move( jv.get_array() )` if `jv.is_array()`, or 0092 0093 @li `std::move( jv.get_object() )` if `jv.is_object()`, or 0094 0095 @li `std::move( jv.get_string() )` if `jv.is_string()`, or 0096 0097 @li `std::move( jv.get_int64() )` if `jv.is_int64()`, or 0098 0099 @li `std::move( jv.get_uint64() )` if `jv.is_uint64()`, or 0100 0101 @li `std::move( jv.get_double() )` if `jv.is_double()`, or 0102 0103 @li `std::move( jv.get_bool() )` if `jv.is_bool()`, or 0104 0105 @li `std::nullptr_t()` if `jv.is_null()`. 0106 0107 @return The value returned by Visitor. 0108 0109 @param v The visitation function to invoke 0110 0111 @param jv The value to visit. 0112 */ 0113 template<class Visitor> 0114 auto 0115 visit( 0116 Visitor &&v, 0117 value&& jv) -> decltype( 0118 static_cast<Visitor&&>(v)( std::declval<std::nullptr_t&&>() ) ); 0119 0120 } // namespace json 0121 } // namespace boost 0122 0123 #include <boost/json/impl/visit.hpp> 0124 0125 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|