Trying to sort shared data with a predicate causes 'unable to format shared objects'

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 16 21:38:18 PDT 2014


On 06/16/2014 07:45 PM, George Sapkin wrote:
> I'm trying to sort shared data with a predicate. Buy that causes 'unable
> to format shared objects'. Here's an example reproducing the issue
> without any threading code:
>
> shared class SomeClass {
>     immutable int value;
>
>     this(const int value) {
>        this.value = value;
>     }
> }
>
> void main() {
>      auto n = 10;
>      auto data = new shared SomeClass[n];
>
>      foreach (i; 0..n) data[i] = new shared SomeClass(i);
>      auto sorted = sort!((a, b) => a.value < b.value)(data);
> }

Good news: The code compiles with 2.066 after adding 'import 
std.algorithm;' :)

Ali



More information about the Digitalmars-d-learn mailing list