![]() |
TerraForge3D
2.3.1
3D Terrain And Landscape Generator
|
|
inlinenoexcept |
create a JSON value
This is a "catch all" constructor for all compatible JSON types; that is, types for which a to_json()
method exists. The constructor forwards the parameter val to that method (to json_serializer<U>::to_json
method with U = uncvref_t<CompatibleType>
, to be exact).
Template type CompatibleType includes, but is not limited to, the following types:
std::vector
, std::deque
, std::list
, std::forward_list
, std::array
, std::valarray
, std::set
, std::unordered_set
, std::multiset
, and std::unordered_multiset
with a value_type
from which a basic_json value can be constructed.std::map
, std::unordered_map
, std::multimap
, and std::unordered_multimap
with a key_type
compatible to string_t and a value_type
from which a basic_json value can be constructed.int
, size_t
, int64_t
, float
or double
can be used.bool
can be used.std::vector<std::uint8_t>
may be used, unfortunately because string literals cannot be distinguished from binary character arrays by the C++ type system, all types compatible with const char*
will be directed to the string constructor instead. This is both for backwards compatibility, and due to the fact that a binary type is not a standard JSON type.See the examples below.
CompatibleType | a type such that:
|
U | = uncvref_t<CompatibleType> |
[in] | val | the value to be forwarded to the respective constructor |
@complexity Usually linear in the size of the passed val, also depending on the implementation of the called to_json()
method.
@exceptionsafety Depends on the called constructor. For types directly supported by the library (i.e., all types for which no to_json()
function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any JSON value.
@liveexample{The following code shows the constructor with several compatible types.,basic_json__CompatibleType}
Definition at line 19260 of file json.hpp.