Skip to content

Fixing Allocator support in Trial.Json #35

@glenfe

Description

@glenfe

This library looks good, and good things provoke requests like these. Here's an initial list:

  • An Allocator doesn't have to be a template with a single parameter. i.e. The template parameter shouldn't be template<typename> class Allocator but instead just class Allocator. You can default it to std::allocator<char>, it doesn't matter, since you'll be rebinding as necessary.

  • An Allocator doesn't have to be default constructible or stateless. All functions should accept an allocator instance, const Allocator& a. You can default this to an instance of Allocator() but users who use allocators where this is not an option, can supply the appropriate instance.

  • Allocator construction shouldn't use addressof(*ptr) but instead to_address(ptr) (using addressof(*ptr) here before ptr references an object of T is undefined behavior).

  • Allocators might be final so do not derive from them unconditionally. Instead of deriving from Allocator, derive from a facility like boost::empty_value<Allocator> (which will use inheritance if not final, or otherwise just store a member).

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