View mode: basic / threaded / horizontal-split · Log in · Help
April 29, 2008
Re: SwapStrategy issues again...
Argh, sorry, meant this to be a new topic post. I'll try again.

Brian Myers Wrote:

> I'm getting the following error messages now. Does SwapStrategy have to be specified at compile time?
> 
> C:\Documents and Settings\dag033\D\d_dedup>dmd -g d_dedup.d ..\d_libcsv\d_libcsv.d ..\d_libcsv\csv.d ..\d_libcsv\bin\deb
> ug\d_libcsv.lib
> c:\dmd\bin\..\src\phobos\std\algorithm.d(2632): Error: expression ss == cast(SwapStrategy)0 is not constant or does not
> evaluate to a bool
> c:\dmd\bin\..\src\phobos\std\algorithm.d(2655): static assert  (ss != cast(SwapStrategy)1) is not evaluatable at compile
>  time
> 
> Here's the call to schwartzSort!:
> 
> protected:
>     SwapStrategy ss;
> .
> .
> .
> schwartzSort!(kx.get_key, "a < b", ss)(lines);
> 
> Thanx
> 
> Brian
>
April 30, 2008
Re: Automatic Foreach
Bruno Medeiros wrote:
> janderson wrote:
>> while back I wrote a template that works like:
>>
>> void foo(int i)
>> {
>>   printf("B");
>> }
>>
>> alias AutoForeach!(foo, int) foo;
>>
>> Then I could go:
>>
>> for(6); //Prints "B"
>> int[] array;
>> array = 2;
>> foo(array); //Prints "BB"
>>
>> But then I couldn't specialize it later without removing the alias, 
>> because I'd get a name clash.
>>
>> The other problem is this won't do cases like:
>>
>> result ~= foo(array);
>>
> 
> Why not? Didn't you define AutoForeach!(foo, int) to return an int[] ?

Your right a AutoForEachReturn could work here.

> 
>> or
>>
>> foo(foo1(array));  //Runs foo and foo1 array.length times.
>>
>>

I forgot to mention that in that example foo1 was defined with the 
autoforeach, foo was not (and it wouldn't work even if I did).

> 
> Same as above.
>
Next ›   Last »
1 2 3 4
Top | Discussion index | About this forum | D home