Boost logo

Boost :

Subject: Re: [boost] [lclcontext] Any interest in Pythonesque "with-as" statement in C++.
From: Sam Kellett (samkellett_at_[hidden])
Date: 2015-08-17 12:48:55

> I didn't know that. I was only targeting C++03/C++11.

This should work with C++11:

template <typename T, typename F>
void with(T &&t, F &&fn)

with(make_foo(), [](foo &&f) {
  // do things with foo.
}); // foo is destroyed.

Don't think I can help w/r/t C++03 though, the lack of lambdas is a killer.

Boost list run by bdawes at, gregod at, cpdaniel at, john at