> The strange thing is, the existence of the private "explicit ScopeWarden(F&&);"
> prevents my template function creation approach from working with regular function pointers.

Are you saying &func? That's an rvalue (observe that &(&func) would be bogus).

ScopeWarden could be partially specialized for function pointers (it's just obnoxious if you want to handle arbitrary calling conventions).

> The constructor for f can still throw an exception, even if the ScopeWarden cannot.

Yeah, ScopeWarden can't defend against that. "Don't do that then."

> Is there any strong guarantee in the standard that construction of a lambda won't throw an exception?

Lambdas with value captures of throwing types obviously can. The Standard appears to be silent about stateless lambdas, and lambdas with only value captures of non-throwing types (e.g. int) and reference captures, but no sane implementation will ever emit exceptions for those.

> Personally, if I were to use a class like this for transaction semantics, I'd probably use it like this:
> SCOPE_WARDEN(if( isXDone ) UndoX()Wink;DoX();

Ah, but then X needs to record that it's done.

> This circumvents the whole issue of throwing exceptions in the ctor.

The SCOPE_WARDEN macro already avoids that.

> Ultimately the question here is: how would you define your ScopeWarden to be usablewithout
> a macro, but still require only a single statement to use and not require explicitly
> stating the template parameter? That's what I've been trying to do (more as a thought
> exercise rather than for anything practical), and what I think Jonas_No's goal was too.

I don't think it can be done, and I thought about this for a long time while writing ScopeWarden.