D-Programming-Language/phobos — pull request #1215 by monarchdodra (2013-03-20 11:10:18+00:00)
Title: Improve scoped implementation

This changes the `scoped(T, Args...)` *function*, into a template parametrized on T, that returns a function parametrized on Args. EG:

```D
template scoped(T)
if (is(T == class))
{
private static struct Scoped;
@system auto scoped(Args...)(auto ref Args args);
}
```

The advantages are:
1. The Scoped struct definition depends only on the type `T` (previously, a new definition existed for each and every combination of `Args`)
2. It allows aliasing and instantiating the template, to get a template function that is ready for future use.

Finally, I gave `Scoped` an `@disabled this()` to prevent our smarter users from trying to build a Scoped using `typeof`.

Also, moved example into a documented unittest.