PR 1360 revived: Add clamp function

https://github.com/D-Programming-Language/phobos/pull/1360

As original author did not respond to reviewer comments for some time, I have made necessary changes and created new PR for it.
Okay, that's a battle for another day, then.