Re: T opImplCast(T)() so we can add @disable to it?

2018-05-24 Thread John Colvin via Digitalmars-d
On Thursday, 24 May 2018 at 07:37:40 UTC, Sjoerd Nijboer wrote: On Thursday, 24 May 2018 at 07:06:03 UTC, Bastiaan Veelo wrote: On Thursday, 24 May 2018 at 06:42:51 UTC, Sjoerd Nijboer wrote: On Thursday, 24 May 2018 at 01:39:56 UTC, Jonathan M Davis wrote: If you don't want an implict cast, th

Re: T opImplCast(T)() so we can add @disable to it?

2018-05-24 Thread Sjoerd Nijboer via Digitalmars-d
On Thursday, 24 May 2018 at 07:06:03 UTC, Bastiaan Veelo wrote: On Thursday, 24 May 2018 at 06:42:51 UTC, Sjoerd Nijboer wrote: On Thursday, 24 May 2018 at 01:39:56 UTC, Jonathan M Davis wrote: If you don't want an implict cast, then why did you declare an alias this? Because I wanted an inco

Re: T opImplCast(T)() so we can add @disable to it?

2018-05-24 Thread Bastiaan Veelo via Digitalmars-d
On Thursday, 24 May 2018 at 06:42:51 UTC, Sjoerd Nijboer wrote: On Thursday, 24 May 2018 at 01:39:56 UTC, Jonathan M Davis wrote: If you don't want an implict cast, then why did you declare an alias this? Because I wanted an inconvertible type which was exactly like the int in the example but

Re: T opImplCast(T)() so we can add @disable to it?

2018-05-23 Thread Sjoerd Nijboer via Digitalmars-d
On Thursday, 24 May 2018 at 01:39:56 UTC, Jonathan M Davis wrote: If you don't want an implict cast, then why did you declare an alias this? Because I wanted an inconvertible type which was exactly like the int in the example but didn't want the implicit cast. That's the whole point of alias

Re: T opImplCast(T)() so we can add @disable to it?

2018-05-23 Thread Jonathan M Davis via Digitalmars-d
On Thursday, May 24, 2018 00:30:03 Sjoerd Nijboer via Digitalmars-d wrote: > While tinkering with some code I eventually found that the > following didn't do as I expected > > import std.conv; > import std.stdio; > > void main() > { > Foo foo = 5; > writeln(foo); > } > > struct Foo{ >

Re: T opImplCast(T)() so we can add @disable to it?

2018-05-23 Thread Sjoerd Nijboer via Digitalmars-d
I would REALLY love a way to implement an implicit cast that wasn't `alias this` based... for reasons that are NOT to @disable it :P Well, explicit casts can be annoying at times when type conversion wouldn't mean loss of precision, but disabling an implicit cast on any type that has such c

Re: T opImplCast(T)() so we can add @disable to it?

2018-05-23 Thread Sjoerd Nijboer via Digitalmars-d
On Thursday, 24 May 2018 at 00:53:00 UTC, Manu wrote: I would REALLY love a way to implement an implicit cast that wasn't `alias this` based... for reasons that are NOT to @disable it :P Well, explicit casts can be annoying at times when type conversion wouldn't mean loss of precision, but di

Re: T opImplCast(T)() so we can add @disable to it?

2018-05-23 Thread Manu via Digitalmars-d
On 23 May 2018 at 17:30, Sjoerd Nijboer via Digitalmars-d wrote: > While tinkering with some code I eventually found that the following didn't > do as I expected > > import std.conv; > import std.stdio; > > void main() > { > Foo foo = 5; > writeln(foo); > } > > struct Foo{ > int i; >

T opImplCast(T)() so we can add @disable to it?

2018-05-23 Thread Sjoerd Nijboer via Digitalmars-d
While tinkering with some code I eventually found that the following didn't do as I expected import std.conv; import std.stdio; void main() { Foo foo = 5; writeln(foo); } struct Foo{ int i; alias i this; @disable T opCast(T)(); this(int j) {i =j;} } If the cast in