Re: is(this : myClass)

2017-10-21 Thread Patrick via Digitalmars-d-learn
But with the current compiler you would never write is(typeOf(myC) : typeof(c)) if in your mind "c" is actually a class "C" because if that is in your mind you would just write is(typeof(myC) : c) which would get you the error. You only need typeof(variable) to get to the type, there is

Re: is(this : myClass)

2017-10-21 Thread Igor via Digitalmars-d-learn
o be clear and unambiguous to the compiler. Otherwise debugging would be hell. Not asking the compiler to fix my errors. When would is(this, myClass) not mean: is(typeof(this) : typeof(myClass))? class C { } int c; C myC; is(myC : c); oops, forgot to capitalize. But compiler says "I kn

Re: is(this : myClass)

2017-10-20 Thread Patrick via Digitalmars-d-learn
ging would be hell. Not asking the compiler to fix my errors. When would is(this, myClass) not mean: is(typeof(this) : typeof(myClass))? class C { } int c; C myC; is(myC : c); oops, forgot to capitalize. But compiler says "I know, you really meant is(typeof(myC) : typeof(c)) -> fals

Re: is(this : myClass)

2017-10-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/20/17 7:04 PM, user1234 wrote: Strangely this is not always true, in other contexts this is seen as atype, although probably a bug class Foo {     class Bar : this {}     static assert(is(Bar : Foo)); } Definitely a bug. You should have to write typeof(this) (which is valid in this

Re: is(this : myClass)

2017-10-20 Thread Steven Schveighoffer via Digitalmars-d-learn
When would is(this, myClass) not mean: is(typeof(this) : typeof(myClass))? class C { } int c; C myC; is(myC : c); oops, forgot to capitalize. But compiler says "I know, you really meant is(typeof(myC) : typeof(c)) -> false. -Steve

Re: is(this : myClass)

2017-10-20 Thread user1234 via Digitalmars-d-learn
On Friday, 20 October 2017 at 21:42:32 UTC, Jonathan M Davis wrote: On Friday, October 20, 2017 21:32:48 Patrick via Digitalmars-d-learn wrote: The compiler seems to reject the following code in a class method: bool test = is(this : myClass); Could some please explain

Re: is(this : myClass)

2017-10-20 Thread Patrick via Digitalmars-d-learn
generally doesn't "fix" errors for you, it tells you there is a problem, and then you have to fix it. You have to be clear and unambiguous to the compiler. Otherwise debugging would be hell. -Steve Not asking the compiler to fix my errors. When would is(this, myClass) not mean:

Re: is(this : myClass)

2017-10-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/20/17 5:55 PM, Patrick wrote: Due to the very specific nature of the 'is' operator, why wouldn't the compiler know to implicitly query the class types? Why must it be explicitly written, typeof(this)? The compiler generally doesn't "fix" errors for you, it tells you there is a problem,

Re: is(this : myClass)

2017-10-20 Thread Patrick via Digitalmars-d-learn
On Friday, 20 October 2017 at 21:42:32 UTC, Jonathan M Davis wrote: On Friday, October 20, 2017 21:32:48 Patrick via Digitalmars-d-learn wrote: The compiler seems to reject the following code in a class method: bool test = is(this : myClass); Could some please explain

Re: is(this : myClass)

2017-10-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, October 20, 2017 21:32:48 Patrick via Digitalmars-d-learn wrote: > The compiler seems to reject the following code in a class method: > > bool test = is(this : myClass); > > Could some please explain this? "this" is not a type. is(T : U) is true if T is impli

is(this : myClass)

2017-10-20 Thread Patrick via Digitalmars-d-learn
The compiler seems to reject the following code in a class method: bool test = is(this : myClass); Could some please explain this? Thanks, Patrick

RedBlackTree and myClass

2016-01-03 Thread AntonSotov via Digitalmars-d-learn
import std.container.rbtree; class myClass { string str; } int main() { auto tree = new RedBlackTree!myClass; return 0; } Error: mutable method object.Object.opCmp is not callable using a inout object Error: template instance std.functional.binaryFun!("a < b&qu

Re: RedBlackTree and myClass

2016-01-03 Thread Tobi G. via Digitalmars-d-learn
On Sunday, 3 January 2016 at 14:49:59 UTC, tsbockman wrote: On Sunday, 3 January 2016 at 10:55:05 UTC, AntonSotov wrote: import std.container.rbtree; class myClass { string str; } int main() { auto tree = new RedBlackTree!myClass; return 0; } Error: mutable method

Re: RedBlackTree and myClass

2016-01-03 Thread AntonSotov via Digitalmars-d-learn
tsbockman, Many thanks! Now I work for me

Re: RedBlackTree and myClass

2016-01-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, January 03, 2016 10:55:05 AntonSotov via Digitalmars-d-learn wrote: > import std.container.rbtree; > > class myClass { > string str; > } > > > int main() > { > auto tree = new RedBlackTree!myClass; > return 0; > } > > &

Re: RedBlackTree and myClass

2016-01-03 Thread tsbockman via Digitalmars-d-learn
On Sunday, 3 January 2016 at 10:55:05 UTC, AntonSotov wrote: import std.container.rbtree; class myClass { string str; } int main() { auto tree = new RedBlackTree!myClass; return 0; } Error: mutable method object.Object.opCmp is not callable using a inout object Error: template

Re: RedBlackTree and myClass

2016-01-03 Thread tsbockman via Digitalmars-d-learn
often use the 'less' in the template arguments to get such things as comparison done, and implement these functions only if i have to.. To get it work this should be enough: import std.container.rbtree; class myClass { string str; override string toString() const { return

Re: RedBlackTree and myClass

2016-01-03 Thread Tobi G. via Digitalmars-d-learn
On Sunday, 3 January 2016 at 16:44:35 UTC, tsbockman wrote: If it's a private internal data structure which is only used a few places, then sure - just use the minimum code required to get the job done. But, if it's a part of the public API for a module and the class logically has a natural

class MyClass(T) : Base if (ConstraintExpression) {} compilation error

2013-05-24 Thread ref2401
Version D 2.062 Please explain what is causing the error class Base { } class Class(T) : Base if (is(T == int)) { } Error: unrecognized declaration Error: members expected Error: Declaration expected, not 'if' Error: { } expected following aggregate declaration

Re: class MyClass(T) : Base if (ConstraintExpression) {} compilation error

2013-05-24 Thread Simen Kjaeraas
On 2013-05-24, 16:49, ref2401 wrote: Version D 2.062 Please explain what is causing the error class Base { } class Class(T) : Base if (is(T == int)) { } Error: unrecognized declaration Error: members expected Error: Declaration expected, not 'if' Error: { } expected following aggregate

Re: class MyClass(T) : Base if (ConstraintExpression) {} compilation error

2013-05-24 Thread Maxim Fomin
On Friday, 24 May 2013 at 14:49:24 UTC, ref2401 wrote: Version D 2.062 Please explain what is causing the error class Base { } class Class(T) : Base if (is(T == int)) { } Error: unrecognized declaration Error: members expected Error: Declaration expected, not 'if' Error: { } expected