Filling a char array with letters and element type of char[]

Kadir Erdem Demir via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 3 00:18:34 PST 2015


I have an char[];

char[] strArr = "http://www.hurriyet.com.tr/ekonomi".dup;

I stripped the domain out of url like:

auto domain = findSplitAfter(strArr, "http://")[1].until('/');

Than because I am new to the language I became curious if I 
change domain(which I believe a input iterator); the values of 
strArr will also change or not. I tried to to modify domain like :

fill(domain, 'a');

Which gives error :
"cannot deduce function from argument types !()(Until!("a == b", 
char[], char), char)"

But if the array is a array of ints it compiles. I believe it 
fails because in compile messages I see

std.algorithm.fill(Range, Value)(Range range, Value filler) if 
(isInputRange!Range && is(typeof(range.front = filler)))

and

writeln( is(typeof(url.front = 'a')) );  ---> false
writeln( is(typeof(intArr.front = 0)) ); ---> true(that is why 
compiles)

I have three questions?

If I change the iterator which I get from algorithm, the owner 
data will change or not?

How to use std.algorithm.fill with char types?

What is the type of char array holds why it does not matches char?

Regards
Kadir Erdem


More information about the Digitalmars-d-learn mailing list