Standard Template Library Support¶
Glaze uses C++20 concepts to not only support the standard template library, but also other libraries or custom types that conform to the same interface.
Array Types¶
Array types logically convert to JSON array values. Concepts are used to allow various containers and even user containers if they match standard library interfaces.
std::tuplestd::arraystd::vectorstd::dequestd::liststd::forward_liststd::spanstd::setstd::unordered_set
Object Types¶
glz::object(compile time mixed types)std::mapstd::unordered_map
Variants¶
std::variant
Variants support auto-deduction and tagged types. Smart pointers (std::unique_ptr, std::shared_ptr) are fully supported as variant alternatives, including with tagged variants.
See Variant Handling for more information.
Nullable Types¶
std::unique_ptrstd::shared_ptrstd::optional- Raw pointers (
T*)
Nullable types may be allocated by valid input or nullified by the null keyword. Smart pointers can also be used as variant alternatives (e.g., std::variant<std::unique_ptr<A>, std::unique_ptr<B>>), see Variant Handling for details.
[!NOTE] Raw pointers work with automatic reflection and respect the
skip_null_membersoption. See Nullable Types for detailed information about pointer handling.
String Types¶
std::stringstd::string_viewstd::filesystem::path-
Note that
std::filesystem::pathdoes not work with pure reflection on GCC and MSVC (requires a glz::meta) -
std::bitset
std::expected¶
std::expected is supported where the expected value is treated as it would typically be handled in JSON, and the unexpected value is treated as a JSON object with the unexpected value referred to by an "unexpected" key.
Example of unexpected: