sort and shared
Adam Conner-Sax
adam_conner_sax at yahoo.com
Thu Jan 20 18:14:06 PST 2011
The following code:
import std.algorithm;
class Foo {
private:
int id_;
public:
shared int id() const { return id_; }
}
static bool compare(in shared(Foo) a, in shared(Foo) b)
{
return (a.id() < b.id());
}
void main()
{
shared Foo a,b,c;
shared(Foo)[] uFooArray = [a,b,c];
sort!(compare)(uFooArray);
}
fails to compile with
usr/local/src/dmd2/src/phobos/std/conv.d(295): Error: function
object.Object.toString () is not callable using argument types ()
whereas if I just take all the shared away it compiles fine. I imagine that
this is somewhere to do with a string function being called on an element of
the array and then there's no shared version of that method.
Is there a fix? Or a different way to call sort? I can cast away shared for
the sort but since in the actual application I have a reason for it, that's a
bit worrisome.
Thanks!
Adam
Adam
begin 644 test.d
M:6UP;W)T('-T9"YA;&=O<FET:&T["@IC;&%S<R!&;V\@"GL*<')I=F%T93H*
M("!S=&%T:6,@:6YT(&YE>'1?:61?(#T@,#L*("!I;G0@:61?.PH@('1H:7,H
M*2![(&ED7R`](&YE>'1?:61?*RL[('T*<'5B;&EC. at H@('-H87)E9"!I;G0@
M:60H*2!C;VYS="![(')E='5R;B!I9%\[('T*?0H*"G-T871I8R!B;V]L(&-O
M;7!A<F4H:6X@<VAA<F5D*$9O;RD at 82P@:6X@<VAA<F5D*$9O;RD at 8BD@"GL*
M("!R971U<FX@*&$N:60H*2`\(&(N:60H*2D["GT*"G9O:60@;6%I;B at I(`I[
M"B`@<VAA<F5D($9O;R!A+&(L8SL*("!S:&%R960H1F]O*5M=('5&;V]!<G)A
M>2`](%MA+&(L8UT["B`@<V]R="$H8V]M<&%R92DH=49O;T%R<F%Y*3L*?0``
`
end
More information about the Digitalmars-d-learn
mailing list