understanding std.algorithm.mutation.fill behaivor.

Nemanja Boric via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 28 00:10:41 PST 2016


On Wednesday, 28 December 2016 at 05:09:34 UTC, LeqxLeqx wrote:
> Perhaps this is a stupid question, and I apologize if it is, 
> but why doesn't this compile:
>
>   import std.algorithm;
>   import std.stdio;
>   void main()
>   {
> 	  char[] array = [1, 2, 3, 4];
> 	  char value = 2;
> 	  fill(array, value);
>   }
>
> if this does:
>
>   import std.algorithm;
>   import std.stdio;
>   void main()
>   {
> 	  int[] array = [1, 2, 3, 4];
> 	  int value = 2;
> 	  fill(array, value);
>   }
>
> when the only difference is the type, and the 'fill' method is 
> meant to be generic?
>
> Thanks for your time.

So I don't repeat excellent answer: 
http://stackoverflow.com/a/6401889/133707


More information about the Digitalmars-d-learn mailing list