On Friday, 26 January 2018 at 15:33:03 UTC, aliak wrote:
On Friday, 26 January 2018 at 14:35:25 UTC, Meta wrote:
On Friday, 26 January 2018 at 14:16:04 UTC, aliak wrote:
1) I've seen some phobos code checking for assignability like this:

  is(typeof(range.front = false))

... is that an advantage of that over hasAssignableElements? Or is that just basically combining constraints 3 and 4 which I have above?

Where did you see this? That's got to be some very old code; I can't think of any instance where you would not want to use `hasAssignableElements` instead.

Seems to occur in https://github.com/dlang/phobos/blob/v2.078.1/std/algorithm/mutation.d

eg: https://github.com/dlang/phobos/blob/v2.078.1/std/algorithm/mutation.d#L555

The function is called fill, and assigns a value to every element in the range. If a[0] = false compiles, we also want a.fill(false) to compile. It's simply testing that, rather than caring about the exact type of the elements.

--
  Simen

Reply via email to