Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-30 Thread Matt via Digitalmars-d-learn
On Tuesday, 30 July 2019 at 05:30:30 UTC, Jonathan M Davis wrote: In principle, it's good to use const when you know that data isn't going to change, but that gets far more complicated when you're dealing with generic code or even with classes, since as soon as you use const, everything used wi

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, July 29, 2019 3:11:45 PM MDT Matt via Digitalmars-d-learn wrote: > On Monday, 29 July 2019 at 19:38:34 UTC, Jonathan M Davis wrote: > > On Monday, July 29, 2019 11:32:58 AM MDT Matt via > > Digitalmars-d-learn wrote: > > > > > > > > Because const ranges are basically useless, there reall

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread Matt via Digitalmars-d-learn
On Monday, 29 July 2019 at 19:38:34 UTC, Jonathan M Davis wrote: On Monday, July 29, 2019 11:32:58 AM MDT Matt via Digitalmars-d-learn wrote: Because const ranges are basically useless, there really isn't much point in putting const on any range functions even if it would work for that pa

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread ag0aep6g via Digitalmars-d-learn
On 29.07.19 21:35, H. S. Teoh wrote: Generally, the idiom is to let the compiler do attribute inference by templatizing your code and not writing any explicit attributes, then use unittests to ensure that instantiations of the range that ought to have certain attributes actually have those attrib

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, July 29, 2019 1:35:18 PM MDT H. S. Teoh via Digitalmars-d-learn wrote: > Generally, the idiom is to let the compiler do attribute inference by > templatizing your code and not writing any explicit attributes, then use > unittests to ensure that instantiations of the range that ought to

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, July 29, 2019 11:32:58 AM MDT Matt via Digitalmars-d-learn wrote: > I've noticed that for some ranges in Phobos empty is marked const > (e.g. iota) but for other ranges (e.g. multiwayMerge) it is not > const. Is there a reason why? Isn't empty guaranteed not to alter > the data of the ra

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 29, 2019 at 05:32:58PM +, Matt via Digitalmars-d-learn wrote: > I've noticed that for some ranges in Phobos empty is marked const > (e.g. iota) but for other ranges (e.g. multiwayMerge) it is not > const. Is there a reason why? Isn't empty guaranteed not to alter the > data of the

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread Eduard Staniloiu via Digitalmars-d-learn
On Monday, 29 July 2019 at 17:32:58 UTC, Matt wrote: I've noticed that for some ranges in Phobos empty is marked const (e.g. iota) but for other ranges (e.g. multiwayMerge) it is not const. Is there a reason why? Isn't empty guaranteed not to alter the data of the range and so should be const?