std.algorithm.sorting fails with obscure errors when using Array!T and opSlice()
我确定这里缺少明显的东西-D的其余部分(甚至是编译器错误)都非常明智且易于理解。我有一个类似结构的
但是,如果我将两个非常普通的类型制成
1 2 3 4 | B:\\lib\\D\\dmd2\\windows\\bin\\..\\..\\src\\phobos\\std\ ange\\package.d(7189): Error: 'std.range.SortedRange!(RangeT!(Array!(MyInt)),"a < b").SortedRange.dbgVerifySorted' is not nothrow B:\\lib\\D\\dmd2\\windows\\bin\\..\\..\\src\\phobos\\std\\algorithm\\sorting.d(982): Error: template instance std.range.assumeSorted!("a < b", RangeT!(Array!(MyInt))) error instantiating main.d(21): instantiated from here: sort!("a < b", cast(SwapStrategy)0, RangeT!(Array!(MyInt))) |
下面的最小示例。第一个
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import std.array; import std.container.array; import std.algorithm.sorting; struct MyInt { int data; int opCmp(MyInt o) { return data - o.data; } } int main(string[] argv) { MyInt ami, bmi; Array!MyInt arr = [ ami, bmi ]; sort([ami, bmi]); sort(arr[0..2]); sort(arr[]); sort(arr.opSlice()); return 0; } |
这是Phobos中的错误:问题#14981
该问题已在一个月前修复,但尚未对其发布进行任何更改。可能将在2.069中提供。
目前,您可以在发布模式下构建项目。