Re: Why an abstract pointer cannot be used as value in an associate array?
Cheng Wei: > extern(C) { > struct ab; > } > > ab*[int] map; > > void main() { > map.clear(); > } > > > Cannot be compiled. Why? It's not specific of associative arrays: extern(C) { struct AB; } AB*[] arr; void main() { arr.length += 1; } Bye, bearophile
Why an abstract pointer cannot be used as value in an associate array?
extern(C) { struct ab; } ab*[int] map; void main() { map.clear(); } Cannot be compiled. Why? Thanks.
Re: Multithreaded file IO?
trav...@phare.normalesup.org (Christophe) writes: > Jerry Quinn , dans le message (digitalmars.D.learn:29763), a écrit : >> What I really want is a shared fifo where the input is lines from a >> file, and many workers grab something from the fifo. They then push >> their results into a shared reordering output queue. > > My 2 cent advice: > > Does the queue really has to be a file ? > You could read it completely before starting, and then just share > your instructions as strings for example. Yes, these files could be large enough that the memory cost of loading is an issue. Also, I should be able to do this with input from stdin. At this point, I'm trying to figure out how to implement a shared fifo in D as much as solve my original problem :-) Jerry
Re: Using allSatisfy with template that takes multiple type arguments
Thanks, that works. I'll report the bug as well.
Re: Using allSatisfy with template that takes multiple type arguments
Andrej Mitrovic: > But the compiler thinks I'm doing C-style casts so this doesn't work. Any > clues? This seems to work (eye the base of the recursion): template satisfies(T, alias P) { enum satisfies = P!T; } template anyPredicateSatisfy(T, Preds...) { static if (Preds.length) //enum bool anyPredicateSatisfy = (Preds[0]!T) || anyPredicateSatisfy!(T, Preds[1 .. $]); enum bool anyPredicateSatisfy = satisfies!(T, Preds[0]) || anyPredicateSatisfy!(T, Preds[1 .. $]); else enum bool anyPredicateSatisfy = false; } template is4(T) { enum is4 = T.sizeof == 4; } template signed(T) { enum signed = T.min != 0; } static assert(anyPredicateSatisfy!(int, is4, signed)); void main() {} Maybe the error on (Preds[0]!T) is fodder for Bugzilla. Bye, bearophile
Re: Using allSatisfy with template that takes multiple type arguments
Andrej Mitrovic , dans le message (digitalmars.D.learn:29825), a écrit : > Thanks for the tips guys. I have another similar issue now, I want to > check whether a type passes any of the predicates I list. This would > be similar to anySatisfy, however anySatisfy takes one predicate and > multiple types, and what I need is one type and multiple predicates, > e.g.: > > anyPredicateSatisfy!(int, isNumeric, isIntegral); > > I've tried copying anySatisfy's code and modifying it to work: > > template anyPredicateSatisfy(T, F...) > { > static if (F.length == 0) > { > enum bool anySatisfy = false; > } > else static if (F.length == 1) > { > enum bool anySatisfy = (F[0])!T; > } > else > { > enum bool anySatisfy = (F[0])!T) || anySatisfy!(T, F[1 .. $]); ^ you mean anyPredicateSatisfy > } > } > > But the compiler thinks I'm doing C-style casts so this doesn't work. Any > clues?