D-Programming-Language/phobos — pull request #982 by monarchdodra (2012-11-30 10:33:46+00:00)
Title: Upgrading "save" requirements

The first commit just fixes an issue in `std/internal/uni.d` (which fixes a function no-one uses...)

The second commit is the "meat" commit. Basically, `save` doesn't require an actual type match, but merely construction back to the original type.

This can be problematic if the save is stored in an `auto`, or forwarded straight to a template. In particular, it may instantiate the wrong template, or even fail compile if the result of save is some sort of weird non-range proxy. Things get especially funky if you pass the save to a take or similar.

Keeping this behavior means that you pretty much have to throw `auto bck = r.save;` out the window in favor of `R bck = r.save;` or `typeof(r) bck = r.save;`. More importantly, the one-liners `foo(r.save)` becomes non-valid, for the cases where foo is a template.

Unfortunately, like the hasSlicing pull, this is subject to 8847 http://d.puremagic.com/issues/show_bug.cgi?id=8847 ...

So I'm mostly posting this pull request to "get the ball rolling" regardings discussion, and to increase importance of 8847.