Skip to content

glz::generic - ability to customize type and/or allocator #2277

@meastp-nk

Description

@meastp-nk

I would like to be able to use PMR (polymorphic memory resources / allocators) with glz::generic, but unlike previous versions where I (think I) could achieve this with a glz::basic_json_t< ... >, I think this is no longer possible...?

I need to change the types for array_t and object_ t to something allocator aware, like std::pmr::vector and std::pmr::map (or, more likely, a pmr-enabled boost::unordered_flat_map).

I also need to add allocator-awareness to generic_json, I don't know the best way to achieve this. Perhaps inherit from generic_json in a custom type?

   // Generic json type.
   // Template parameter controls number storage mode for precise integer handling
   template <num_mode Mode = num_mode::f64>
   struct generic_json
   {
      virtual ~generic_json() {}

      using array_t = std::vector<generic_json<Mode>>;
      using object_t = std::map<std::string, generic_json<Mode>, std::less<>>;
      using null_t = std::nullptr_t;
   
      // ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions