More flexible sorted ranges?
    Xinok via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sun Nov  2 11:54:37 PST 2014
    
    
  
On Sunday, 2 November 2014 at 17:21:04 UTC, Ola Fosheim Grøstad 
wrote:
> On Sunday, 2 November 2014 at 16:59:30 UTC, bearophile wrote:
>> Ola Fosheim Grøstad:
>>
>>> Shouldn't sorted range maintain the invariant automatically 
>>> in order to remain typesafe?
>>
>> Yes, of course.
>
> If SortedRange is fixed, please also switch the names of 
> upperBound and lowerBound… They are currently wrong. An 
> upperBound on something should return the values lower than it 
> and a lowerBound should return values larger…
>
> (C++ got it right).
D got it right. C++ returns an iterator which can be a bit 
confusing. D returns a slice so it's meaning is much clearer.
https://en.wikipedia.org/wiki/Upper_and_lower_bounds
http://www.cplusplus.com/reference/algorithm/upper_bound/
    
    
More information about the Digitalmars-d-learn
mailing list