Hi,

A newbie question :

I wrote this simple code :

        import std.array;
        import std.stdio;

        void main()
        {

         char[] a = "mon texte 1".dup;
         char[] b = "abc".dup;
         size_t x   = 4;
         size_t y   = 9;
         replaceInPlace( a, x , y, b );
         writeln( a );
        }

But compilation fails :

/usr/include/dmd/phobos/std/array.d(2052): Error: template std.algorithm.remove cannot deduce function from argument types !()(char[], Tuple!(immutable(uint), uint)), candidates are: /usr/include/dmd/phobos/std/algorithm.d(8542): std.algorithm.remove(SwapStrategy s = SwapStrategy.stable, Range, Offset...)(Range range, Offset offset) if (s != SwapStrategy.stable && isBidirectionalRange!Range && hasLvalueElements!Range && hasLength!Range && Offset.length >= 1) /usr/include/dmd/phobos/std/algorithm.d(8623): std.algorithm.remove(SwapStrategy s = SwapStrategy.stable, Range, Offset...)(Range range, Offset offset) if (s == SwapStrategy.stable && isBidirectionalRange!Range && hasLvalueElements!Range && Offset.length >= 1) /usr/include/dmd/phobos/std/algorithm.d(8757): std.algorithm.remove(alias pred, SwapStrategy s = SwapStrategy.stable, Range)(Range range) if (isBidirectionalRange!Range && hasLvalueElements!Range) inout.d(13): Error: template instance std.array.replaceInPlace!(char, char[]) error instantiating

Don't understand why this doesn't work: it compiles fine and runs perfectly if I change "char[]" by "string" ... don't understand why since the documentation says :
      String literals are immutable (read only).

How this function can change a type that is immutable ?

Thanks for your help.
TSalm




Reply via email to