[Issue 13054] New: pure nothrow @safe std.algorithm.schwartzSort
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Jul 6 05:19:22 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13054
Issue ID: 13054
Summary: pure nothrow @safe std.algorithm.schwartzSort
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
In dmd 2.066beta1 this compiles and works correctly:
void main() pure nothrow @safe @nogc {
import std.algorithm: sort;
import std.math: abs;
int[3] data = [-2, 1, 3];
auto r = data[].sort!q{a.abs < b.abs};
}
But schwartzSort doesn't support each of those tags:
void main() pure nothrow @safe @nogc {
import std.algorithm: schwartzSort;
import std.math: abs;
int[3] data = [-2, 1, 3];
auto r = data[].schwartzSort!abs;
}
temp.d(5,20): Error: pure function 'D main' cannot call impure function
'std.algorithm.schwartzSort!(abs, "a < b", cast(SwapStrategy)0,
int[]).schwartzSort'
temp.d(5,20): Error: safe function 'D main' cannot call system function
'std.algorithm.schwartzSort!(abs, "a < b", cast(SwapStrategy)0,
int[]).schwartzSort'
temp.d(5,20): Error: @nogc function 'D main' cannot call non- at nogc function
'std.algorithm.schwartzSort!(abs, "a < b", cast(SwapStrategy)0,
int[]).schwartzSort'
temp.d(5,20): Error: 'std.algorithm.schwartzSort!(abs, "a < b",
cast(SwapStrategy)0, int[]).schwartzSort' is not nothrow
temp.d(1,6): Error: function 'D main' is nothrow yet may throw
A schwartzSort has to allocate the mapped items, so perhaps it can't be @nogc
(unless you allocate them on the C heap), but I think it can support the other
tags.
--
More information about the Digitalmars-d-bugs
mailing list