On 2013-12-05 02:07, Timothee Cour wrote:
A1.Is there a (clever?) way to achieve the following using a single function call? //does chdir void fun(){ ... string dir0=getcwd; scope(exit) chdir(dir0); chdir(dir); ... } //desired: void fun(){ ... chdir_scoped(dir); ... }
Delegates can be used as well:
chdir_scoped!({
chdir(dir);
});
void chdir_scoped (alias block) ()
{
string dir0=getcwd;
scope(exit) chdir(dir0);
block();
)
--
/Jacob Carlborg
