Skip to content

Implement pimpl_ptr #23

@dkaszews

Description

@dkaszews

glug::regex::engine currently uses std::shared_ptr to implement pimpl pattern and prevent library headers from polluting the global namespace. std::unique_ptr was undesired as it would prevent objects from being copied altogether, making glug::glob::filter and therefore glug::filesystem::explorer uncopyable.

This has very bad consequences for multithreading in #22 , as copies of glug::regex:engine still point to the same underlying implementation, which may or may not be thread-safe. Therefore while constructing threads taking the engine by reference is clearly unsafe, taking it by copy looks safe but actually effectively means the same thing.

Proposed solution is to introduce pimpl_ptr which wraps unique_ptr to provide it a copy constructor which copies the underlying object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions