Question about std.bind

Russel Winder russel at russel.org.uk
Fri Nov 12 11:05:45 PST 2010


I have a function with signature:

        void partialSum ( immutable long start , immutable long end , immutable real delta )

(it turns out the immutable is not a factor here I tried without it and
with const.)

I have a thread creation loop:

        foreach ( i ; 0 .. numberOfThreads ) { threads[i] = new Thread ( bind ( & partialSum , 1 + i * sliceSize , ( i + 1 ) * sliceSize , delta ) ) ; }

but this does not work.  I get the error message as below.  I really
haven't a clue what I am doing wrong, but I bet it is something
trivially simple.

        dmd -I. -O -release -inline -c -ofpi_d2_threads.o pi_d2_threads.d
        /home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/traits.d(185): Error: static assert  "argument has no parameters"
        /home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/bind.d(977):        instantiated from here: ParameterTypeTuple!(const(EmptySlot)*)
        /home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/bind.d(1003):        instantiated from here: FuncReferenceParamsAsPointers_impl!(NullAlias)
        /home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/bind.d(338):        instantiated from here: FuncReferenceParamsAsPointers!(NullAlias)
        /home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/bind.d(660):        instantiated from here: BoundFunc!(void function(immutable immutable(long) start, immutable immutable(long) end, immutable immutable(real) delta),NullAlias,Tuple!(long,long,immutable(double)))
        pi_d2_threads.d(31):        instantiated from here: bind!(void function(immutable immutable(long) start, immutable immutable(long) end, immutable immutable(real) delta),long,long,immutable(double))
        
-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at russel.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20101112/77d19718/attachment.pgp>


More information about the Digitalmars-d mailing list