|
◆ get_ptr() [1/2]
template< template< typename U, typename V, typename... Args > class ObjectType = std::map, template< typename U, typename... Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator, template< typename T, typename SFINAE= void > class JSONSerializer = adl_serializer>
get a pointer value (implicit)
Implicit pointer access to the internally stored JSON value. No copies are made.
- Warning
- Writing data to the pointee of the result yields an undefined state.
- Template Parameters
-
- Returns
- pointer to the internally stored JSON value if the requested pointer type PointerType fits to the JSON value;
nullptr otherwise
- Complexity\n Constant.
- Example\n The example below shows how pointers to internal values of a
- JSON value can be requested. Note that no type conversions are made and a
nullptr is returned if the value and the requested pointer type does not match.
18 std::cout << * p1 << ' ' << * p2 << ' ' << * p3 << ' ' << * p4 << '\n';
19 std::cout << std::boolalpha << ( p5 == nullptr) << '\n';
static basic_json array(std::initializer_list< basic_json > init=std::initializer_list< basic_json >()) explicitly create an array from an initializer list
NumberFloatType number_float_t a type for a number (floating-point)
NumberIntegerType number_integer_t a type for a number (integer)
@ value the parser finished reading a JSON value
PointerType get_ptr() noexcept get a pointer value (implicit)
a class to store JSON values
basic_json<> json default JSON class
Output (play with this example online):
17 17 17 17
true
The example code above can be translated with g++ -std=c++11 -Isrc doc/examples/get_ptr.cpp -o get_ptr
- Since
- version 1.0.0
Definition at line 3389 of file json.hpp.
|