Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread user1234 via Digitalmars-d-learn
On Saturday, 15 June 2019 at 17:42:04 UTC, ag0aep6g wrote: On Saturday, 15 June 2019 at 17:24:45 UTC, user1234 wrote: --- void foo(){writeln(__PRETTY_FUNCTION__);} void main(string[] args) { void delegate() dg; dg.funcptr = dg.ptr = null; // usually a "this" or a frame address

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread ag0aep6g via Digitalmars-d-learn
On Saturday, 15 June 2019 at 17:24:45 UTC, user1234 wrote: --- void foo(){writeln(__PRETTY_FUNCTION__);} void main(string[] args) { void delegate() dg; dg.funcptr = dg.ptr = null; // usually a "this" or a frame address dg(); } --- because dg.ptr would be used to retrieve the

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread user1234 via Digitalmars-d-learn
On Saturday, 15 June 2019 at 16:34:22 UTC, Robert M. Münch wrote: On 2019-06-15 16:19:23 +, Anonymouse said: By design, I think: "delegate and function objects cannot be mixed. But the standard function std.functional.toDelegate converts a function to a delegate." Your example compiles

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread Alex via Digitalmars-d-learn
On Saturday, 15 June 2019 at 16:34:22 UTC, Robert M. Münch wrote: On 2019-06-15 16:19:23 +, Anonymouse said: By design, I think: "delegate and function objects cannot be mixed. But the standard function std.functional.toDelegate converts a function to a delegate." Your example compiles

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-06-15 16:19:23 +, Anonymouse said: By design, I think: "delegate and function objects cannot be mixed. But the standard function std.functional.toDelegate converts a function to a delegate." Your example compiles if the assignment is changed to dg = toDelegate(); (given

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 15 June 2019 at 15:54:00 UTC, Robert M. Münch wrote: Why does the follwing code give: Error: cannot implicitly convert expression & myFunc of type void function(int a) to void delegate(int) void myFunc(int a){return;} void main() { void delegate(int) dg; dg = }

Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread Robert M. Münch via Digitalmars-d-learn
Why does the follwing code give: Error: cannot implicitly convert expression & myFunc of type void function(int a) to void delegate(int) void myFunc(int a){return;} void main() { void delegate(int) dg; dg = } See: https://run.dlang.io/is/iTYo2L -- Robert M. Münch

Re: Error: cannot implicitly convert expression this.aa of type inout(string[string]) to string[string]

2018-03-15 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:41:54 UTC, Robert-D wrote: Why something like this doesn't compile (with or without the cast on bb.dup)? struct S { string[string] aa; S dup() inout pure { return S(cast(string[string]) aa.dup); } } struct SS { S[] bb; SS dup()

Re: Error: cannot implicitly convert expression this.aa of type inout(string[string]) to string[string]

2018-03-15 Thread Robert-D via Digitalmars-d-learn
On Thursday, 15 March 2018 at 13:18:38 UTC, Simen Kjærås wrote: On Thursday, 15 March 2018 at 12:00:08 UTC, Robert-D wrote: I want the function to create a mutable copy from a const or a imutable Like this: void main() { const S s = S(["": ""]); S b = s.dup(); } How can i do that?

Re: Error: cannot implicitly convert expression this.aa of type inout(string[string]) to string[string]

2018-03-15 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 15 March 2018 at 12:00:08 UTC, Robert-D wrote: I want the function to create a mutable copy from a const or a imutable Like this: void main() { const S s = S(["": ""]); S b = s.dup(); } How can i do that? In that case, the problem is that you also have to .dup the aa:

Re: Error: cannot implicitly convert expression this.aa of type inout(string[string]) to string[string]

2018-03-15 Thread Robert-D via Digitalmars-d-learn
On Thursday, 15 March 2018 at 11:33:49 UTC, Simen Kjærås wrote: On Thursday, 15 March 2018 at 11:18:48 UTC, Robert-D wrote: [...] This is where things go wrong: [...] 'inout' means that this function can keep the const, immutable or mutable status of the type on which the function is

Re: Error: cannot implicitly convert expression this.aa of type inout(string[string]) to string[string]

2018-03-15 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 15 March 2018 at 11:18:48 UTC, Robert-D wrote: struct S { string[string] aa; S dup() inout pure { return S(aa); } } void main() { auto s = S(["": ""]); s.dup(); } Result: Error: cannot implicitly convert expression this.aa of type

Error: cannot implicitly convert expression this.aa of type inout(string[string]) to string[string]

2018-03-15 Thread Robert-D via Digitalmars-d-learn
struct S { string[string] aa; S dup() inout pure { return S(aa); } } void main() { auto s = S(["": ""]); s.dup(); } Result: Error: cannot implicitly convert expression this.aa of type inout(string[string]) to string[string] I need help with the above program.

Error: cannot implicitly convert expression

2014-10-23 Thread Suliman via Digitalmars-d-learn
import std.stdio; import std.conv; import std.string; import std.net.curl; void main() { string content = get(d-lang.appspot.com/testUrl2); } Error: cannot implicitly convert expression (get(d-lang.appsp ot.com/testUrl2, AutoProtocol())) of type char[] to string code from: http://dlang.org

Re: Error: cannot implicitly convert expression

2014-10-23 Thread Suliman via Digitalmars-d-learn
Solution http://forum.dlang.org/thread/bgkklxwbhrqdhveth...@forum.dlang.org#post-l639dt:24vlj:241:40digitalmars.com Am I right understand that it's bug in doc?

Re: Error: cannot implicitly convert expression

2014-10-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 23 October 2014 at 19:18:33 UTC, Suliman wrote: Solution http://forum.dlang.org/thread/bgkklxwbhrqdhveth...@forum.dlang.org#post-l639dt:24vlj:241:40digitalmars.com Am I right understand that it's bug in doc? It certainly looks like one. std.net.curl's documentation examples

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-10 Thread Dfr
10, 2013 at 6:54 AM, Dfr defle...@yandex.ru wrote: Hello, here is example code, which doesn't work: Variant[] vtypes = [ Variant(hello), Variant(bye) ]; string[] filetypes = map!(to!string)(vtypes); Gives me error: Error: cannot implicitly convert expression (map(vtypes)) of type

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-10 Thread bearophile
Dfr: auto vtypes = map!(to!Variant[string])(lols); The short template instantiation syntax only supports a single token, to avoid mistakes,so you need to add (): map!(to!(Variant[string]))(lols); That is better written: lols.map!(to!(Variant[string])); But I don't know if this is

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-10 Thread Philippe Sigaud
void main() { Variant[] lols = [ Variant([hello: Variant(1)]), Variant([bye: Variant(true)]) ]; auto vtypes = map!(to!Variant[string])(lols); // --- line 11 string[] filetypes = map!(to!string)(vtypes).array(); writeln(filetypes); } Gives me: main.d(11) Error:

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-10 Thread Dfr
Thank you, this clears thing to me. I currently has all stuff wrapped in Variants because it is structure parsed from xml (or json), and it could be for example map of Something[string], where Something could be string or array or another map, and also this all nested few levels deep. I'm

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-10 Thread Philippe Sigaud
On Wed, Dec 11, 2013 at 7:26 AM, Dfr defle...@yandex.ru wrote: Thank you, this clears thing to me. I currently has all stuff wrapped in Variants because it is structure parsed from xml (or json), and it could be for example map of Something[string], where Something could be string or array

Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-09 Thread Dfr
Hello, here is example code, which doesn't work: Variant[] vtypes = [ Variant(hello), Variant(bye) ]; string[] filetypes = map!(to!string)(vtypes); Gives me error: Error: cannot implicitly convert expression (map(vtypes)) of type MapResult!(to, VariantN!(24u)[]) to string

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-09 Thread Philippe Sigaud
On Tue, Dec 10, 2013 at 6:54 AM, Dfr defle...@yandex.ru wrote: Hello, here is example code, which doesn't work: Variant[] vtypes = [ Variant(hello), Variant(bye) ]; string[] filetypes = map!(to!string)(vtypes); Gives me error: Error: cannot implicitly convert expression (map(vtypes

Error: cannot implicitly convert expression

2013-06-18 Thread Agustin
: cannot implicitly convert expression (handler_) of type shared(HandlerList) to ghrum.event.HandlerList.HandlerList!(PlayerLoginEvent).HandlerList src\Event\Event.d(51): Error: cannot implicitly convert expression (handler_) of type shared(HandlerList) to ghrum.event.HandlerList.HandlerList

Re: Error: cannot implicitly convert expression

2013-06-18 Thread Agustin
!(PlayerLoginEvent) { int x; } src\Event\Event.d(41): Error: cannot implicitly convert expression (handler_) of type shared(HandlerList) to ghrum.event.HandlerList.HandlerList!(PlayerLoginEvent).HandlerList src\Event\Event.d(51): Error: cannot implicitly convert expression (handler_) of type

Re: Error: cannot implicitly convert expression

2013-06-18 Thread Agustin
; } } --- class PlayerLoginEvent : Event!(PlayerLoginEvent) { int x; } src\Event\Event.d(41): Error: cannot implicitly convert expression (handler_) of type shared(HandlerList) to ghrum.event.HandlerList.HandlerList!(PlayerLoginEvent).HandlerList src\Event\Event.d(51): Error: cannot

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-20 Thread Steven Schveighoffer
On Sat, 18 Sep 2010 17:20:31 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Saturday 18 September 2010 09:58:15 Steven Schveighoffer wrote: In reality, you cannot make save const, unless you want to do a deep copy (but I recommend against that, save should be a quick operation).

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-20 Thread Jonathan M Davis
On Monday, September 20, 2010 04:11:05 Steven Schveighoffer wrote: You don't want a deep copy of a range. All you want to copy is the iteration state, not the data. save is definitely supposed to be shallow. I.e. you should copy the range itself, not what the range points to. That makes

Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-18 Thread Jonathan M Davis
Okay, if I try and compile the following program. struct S { @property S save() const { return this; } int[] _val; } void main() { } I get the error message d.d(5): Error: cannot implicitly convert expression (this) of type const(S) to S If I remove const from save

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-18 Thread Ivo Kasiuk
Am Samstag, den 18.09.2010, 02:15 -0700 schrieb Jonathan M Davis: Okay, if I try and compile the following program. struct S { @property S save() const { return this; } int[] _val; } void main() { } Actually, wouldn't it be much more simple to just copy

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-18 Thread Steven Schveighoffer
implicitly convert expression (this) of type const(S) to S Yes, because you are converting this from a const(S) to an S to return it. Try: @property const(S) save() const { return this; } If I remove const from save(), then it works, but with const there, it doesn't. If I change _val

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-18 Thread Jonathan M Davis
On Saturday 18 September 2010 06:45:51 Ivo Kasiuk wrote: Am Samstag, den 18.09.2010, 02:15 -0700 schrieb Jonathan M Davis: Okay, if I try and compile the following program. struct S { @property S save() const { return this; }

Re: ERROR - cannot implicitly convert expression (s) of type int[3u] to int*

2010-06-21 Thread Chick Corea
Thanks for the help, folks. CHICKZ

Re: ERROR - cannot implicitly convert expression (s) of type int[3u] to int*

2010-06-18 Thread Ellery Newcomer
On 06/18/2010 12:25 AM, Chick Corea wrote: [NOTE - sent twice as I was unsure that first attempt, pre-subscription, was received.] Working through the basics of D and running into simple problems that I cannot solve, such as: Error: cannot implicitly convert expression (s) of type int[3u

Re: ERROR - cannot implicitly convert expression (s) of type int[3u] to int*

2010-06-18 Thread Stewart Gordon
Chick Corea wrote: [NOTE - sent twice as I was unsure that first attempt, pre-subscription, was received.] Working through the basics of D and running into simple problems that I cannot solve, such as: Error: cannot implicitly convert expression (s) of type int[3u] to int* Error

Re: ERROR - cannot implicitly convert expression (s) of type int[3u] to int*

2010-06-18 Thread Justin Spahr-Summers
On Fri, 18 Jun 2010 01:25:32 -0400, Chick Corea chick.zco...@gmail.com wrote: Those are the result of code that I pulled directly from the D v1 docs from     http://www.digitalmars.com/d/1.0/arrays.html Specifically, the code is this.         int* p;         int[3] s;         int[] a;

Re: ERROR - cannot implicitly convert expression (s) of type int[3u] to int*

2010-06-18 Thread Don
Stewart Gordon wrote: Chick Corea wrote: [NOTE - sent twice as I was unsure that first attempt, pre-subscription, was received.] Working through the basics of D and running into simple problems that I cannot solve, such as: Error: cannot implicitly convert expression (s) of type int[3u

Re: ERROR - cannot implicitly convert expression (s) of type int[3u] to int*

2010-06-18 Thread Justin Spahr-Summers
On Fri, 18 Jun 2010 08:41:17 -0700, Justin Spahr-Summers justin.spahrsumm...@gmail.com wrote: On Fri, 18 Jun 2010 01:25:32 -0400, Chick Corea chick.zco...@gmail.com wrote: Those are the result of code that I pulled directly from the D v1 docs from