Skip to content

consider adding a cancel policy to scope guard #27

@JeffGarland

Description

@JeffGarland

Look at the comment in this review an consider making a cancel policy

Getting back to the review here. So I think what you're suggesting is something like this:

class always_active_policy
{
  bool is_enabled() { return true; }
};

class cancel_policy
{
   bool enabled = true;
   bool is_enabled() { return enabled; }
   void disable() { enabled = false; };
   void enable() { enabled = true; };
}

template<class EF, class cancellation_policy = always_active_policy>
class scope_success : public cancellation_policy
{}

At which point the user can inject any name they'd like or omit the capability altogether. The later of which seems like the most likely case -- that is never enable/disable.

I think that's an improvement worthy of making - it's just size of bool, but for embedded if this was used extensively it's more not paying for what you don't use.

Note that this might be just a tad more complicated in that maybe this policy goes into the InvokeChecker so it has to be a template template parameter

Originally posted by @JeffGarland in #20 (comment)

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