You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior: is_sorted & is_sorted_until requires only comparator like less
Actual behavior: They require not only comparator but also predicator (equal_to)
Code occuring the bug
Functions is_sorted and is_sorted_until returns invalid value when target elements are not atomic values but custom objects that have not defined the predicator (Object.equals) function.
importstd= require("tstl");functioncomparator(x: std.IPointer<number>,y: std.IPointer<number>): boolean{returnx.value<y.value;}functionmain(): void{letpointers: std.Vector<std.IPointer<number>>=newstd.Vector();for(leti: number=0;i<100;++i)pointers.push_back({value: std.randint(0,10)});std.sort(pointers.begin(),pointers.end(),comparator);console.log(std.is_sorted(pointers.begin(),pointers.end(),comparator));// MUST BE true// BUT PRINTS false}main();
The text was updated successfully, but these errors were encountered:
Functions is_sorted and is_sorted_until are using equal_to function. However, those functions do not provide the matched predicator function. The equal_to must be replaced to !comp(x, y) && !comp(y, x).
Summary
is_sorted
&is_sorted_until
requires only comparator likeless
equal_to
)Code occuring the bug
Functions
is_sorted
andis_sorted_until
returns invalid value when target elements are not atomic values but custom objects that have not defined the predicator (Object.equals
) function.The text was updated successfully, but these errors were encountered: