On Thursday, 14 November 2013 at 19:41:13 UTC, Agustin wrote:
I'm trying to use http://dlang.org/phobos/std_net_curl.html and when i compile the same example i get:

cannot implicitly convert expression (get(cast(const(char)[])address, AutoProtocol())) of type char[] to string

string address = "http://dlang.org";;
string _data = get(address);

You have two options:

string address = "http://dlang.org";;
string _data = get(address).idup(); // create immutable copy

or

string address = "http://dlang.org";;
char[] _data = get(address); // store mutable reference

A string (which is just an alias of immutable(char)[]) can't be made from a char[] without an assertion that the data pointed to is, in fact, immutable. You can do that using assumeUnique (inexplicably found in std.exception).

Reply via email to