Skip to content

Should most allocators be Clone? #88

Closed
@shlevy

Description

@shlevy

I'm creating a data structure that includes Boxes and Vecs and Vecs of Boxes, and I find myself between two choices:

  1. Have the top-level data structure own the Allocator and have each nested structure use the free &A implementation
  2. Require the Allocator to be Clone and just clone it at each usage point

Based on this section in the docs:

cloning or moving the allocator must not invalidate memory blocks returned from this allocator. A cloned allocator must behave like the same allocator

it seems like the expected pattern is 2, and that therefore most allocators will be Clone. Is that correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions