Re: How do you do a typeid(obj) to get the most derived class that it is, or string?

2016-02-01 Thread Ali Çehreli via Digitalmars-d-learn
On 02/01/2016 10:20 PM, Enjoys Math wrote: class A { } class B : A { } class C : B { } auto b = new B(); typeid(b) == "B" ? Thanks. class A { } class B : A { } class C : B { } void main() { auto b = new B(); assert(typeid(b) == typeid(B)); // Or, if you have the ty

How do you do a typeid(obj) to get the most derived class that it is, or string?

2016-02-01 Thread Enjoys Math via Digitalmars-d-learn
class A { } class B : A { } class C : B { } auto b = new B(); typeid(b) == "B" ? Thanks.

Re: Determine type of property

2016-02-01 Thread tsbockman via Digitalmars-d-learn
On Tuesday, 2 February 2016 at 03:36:25 UTC, Steven Schveighoffer wrote: S has 3 different properties, x, y, z: struct S { int x; int y() { return 1;} } int z(S s) { return 1;} pragma(msg, typeof(S.init.x).stringof); // int pragma(msg, typeof(S.init.y).stringof); // int() pragma(msg, typ

Re: how do I tell if something is lvalue?

2016-02-01 Thread tsbockman via Digitalmars-d-learn
On Monday, 1 February 2016 at 22:32:26 UTC, Steven Schveighoffer wrote: What I wanted essentially was a template constraint that says "this type has a member named foo, and t.foo is an lvalue" -Steve Like this? template hasLValProperty(T, string property) { enum hasLValProperty = __trait

Re: D with DerelictASSIMP3 question

2016-02-01 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 2 February 2016 at 03:22:16 UTC, Maeriden wrote: Try aiGetMaterialTextureCount. I'm guessing derelict uses the C API as much as it can. It uses the C API exclusively.

Determine type of property

2016-02-01 Thread Steven Schveighoffer via Digitalmars-d-learn
S has 3 different properties, x, y, z: struct S { int x; int y() { return 1;} } int z(S s) { return 1;} pragma(msg, typeof(S.init.x).stringof); // int pragma(msg, typeof(S.init.y).stringof); // int() pragma(msg, typeof(S.init.z).stringof); // int Is there a trait I can call/use to consis

Re: D with DerelictASSIMP3 question

2016-02-01 Thread Maeriden via Digitalmars-d-learn
On Tuesday, 2 February 2016 at 02:57:14 UTC, WhatMeWorry wrote: I'm porting a C++/opengl/AssImp tutorial over to D/DerelictOpenGL/DerelictAssImp but have hit a brick wall. [...] Try aiGetMaterialTextureCount. I'm guessing derelict uses the C API as much as it can.

D with DerelictASSIMP3 question

2016-02-01 Thread WhatMeWorry via Digitalmars-d-learn
I'm porting a C++/opengl/AssImp tutorial over to D/DerelictOpenGL/DerelictAssImp but have hit a brick wall. It's a fairly large project but a tiny fragment suffices: if(mesh.mMaterialIndex >= 0) { const aiMaterial* material = scene.mMaterials[mesh.mMaterialIndex]; // uint texCount = m

Re: How do you get system time in specified precision?

2016-02-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/1/16 8:17 PM, Enjoys Math wrote: That is in metric system units? Ie milli-, micro-, hectanano-, nano-seconds? Those are available from SysTime.fracSecs. Is that what you are looking for? If not, please be more specific. time has a lot of different meanings. -Steve

How do you get system time in specified precision?

2016-02-01 Thread Enjoys Math via Digitalmars-d-learn
That is in metric system units? Ie milli-, micro-, hectanano-, nano-seconds? The documentation doesn't show this well and many things are deprecated. Please show me how! Thank you.

Re: Region allocator strage error

2016-02-01 Thread mark_mcs via Digitalmars-d-learn
On Monday, 1 February 2016 at 12:05:53 UTC, ref2401 wrote: On Sunday, 31 January 2016 at 14:48:34 UTC, ref2401 wrote: I am getting runtime error: core.exception.AssertError@std\experimental\allocator\building_blocks\region.d(235): Assertion failure At least tell me can anyone replicate it? h

Re: how do I tell if something is lvalue?

2016-02-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/1/16 5:20 PM, tsbockman wrote: On Sunday, 31 January 2016 at 22:11:45 UTC, Steven Schveighoffer wrote: Thanks! I was surprised this is not straightforward. -Steve For function return values, at least, you can do this: import std.traits, std.stdio; int foo() { return 0; } ref int

Re: how do I tell if something is lvalue?

2016-02-01 Thread tsbockman via Digitalmars-d-learn
On Sunday, 31 January 2016 at 22:11:45 UTC, Steven Schveighoffer wrote: Thanks! I was surprised this is not straightforward. -Steve For function return values, at least, you can do this: import std.traits, std.stdio; int foo() { return 0; } ref int bar() { static int x = 0; retu

Re: how do I tell if something is lvalue?

2016-02-01 Thread Meta via Digitalmars-d-learn
On Monday, 1 February 2016 at 20:53:35 UTC, Artur Skawina wrote: On 02/01/16 21:42, Artur Skawina wrote: On 02/01/16 20:47, Meta via Digitalmars-d-learn wrote: That looks much nicer. It still needs work to properly handle functions with non-empty argument lists. Then it gets a bit long for a

Re: Region allocator strage error

2016-02-01 Thread mark_mcs via Digitalmars-d-learn
On Monday, 1 February 2016 at 19:55:26 UTC, mark_mcs wrote: On Monday, 1 February 2016 at 12:05:53 UTC, ref2401 wrote: On Sunday, 31 January 2016 at 14:48:34 UTC, ref2401 wrote: I am getting runtime error: core.exception.AssertError@std\experimental\allocator\building_blocks\region.d(235): Asse

Re: How would you implement this in D? (signals & slots)

2016-02-01 Thread Enjoys Math via Digitalmars-d-learn
On Monday, 1 February 2016 at 21:40:45 UTC, Enjoys Math wrote: module signals_and_slots; import std.algorithm: remove; [...] D's signals & slots: https://dlang.org/phobos/std_signals.html

How would you implement this in D? (signals & slots)

2016-02-01 Thread Enjoys Math via Digitalmars-d-learn
module signals_and_slots; import std.algorithm: remove; struct Slots(DelegateType, ArgTypes...) { this() { } // How would you implement this? void call(ArgTypes args) { foreach (dg; delegates) dg(args); }

Re: how do I tell if something is lvalue?

2016-02-01 Thread Artur Skawina via Digitalmars-d-learn
On 02/01/16 21:42, Artur Skawina wrote: > On 02/01/16 20:47, Meta via Digitalmars-d-learn wrote: >> That looks much nicer. It still needs work to properly handle functions with >> non-empty argument lists. > > Then it gets a bit long for a one-liner ;) > >enum isLvalue(A...) = is(typeof((ref

Re: how do I tell if something is lvalue?

2016-02-01 Thread Artur Skawina via Digitalmars-d-learn
On 02/01/16 20:47, Meta via Digitalmars-d-learn wrote: > On Monday, 1 February 2016 at 18:28:05 UTC, Artur Skawina wrote: >> On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn wrote: >>> Thanks! I was surprised this is not straightforward. >> >>enum isLvalue(alias A) = is(typeof((r

Containers with non copyable types

2016-02-01 Thread maik klein via Digitalmars-d-learn
For example it is no problem in C++ to have std::vector> vuf; But how can this be expressed in D? For example Array!(Unique!int) ua; doesn't compile because it requires this(this) which is obviously disabled for "Unique".

Re: chain(const(array of class)) fails

2016-02-01 Thread SimonN via Digitalmars-d-learn
Sorry for late reply -- but I got around to test a couple more cases! On Monday, 1 February 2016 at 00:19:44 UTC, Nicholas Wilson wrote: Unqaul means remove any const or immutable torn the type Okay, that sounds like our 'const' shouldn't matter. 'const' is the outermost qualifier, and strip

Re: how do I tell if something is lvalue?

2016-02-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/1/16 2:47 PM, Meta wrote: On Monday, 1 February 2016 at 18:28:05 UTC, Artur Skawina wrote: On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn wrote: Thanks! I was surprised this is not straightforward. enum isLvalue(alias A) = is(typeof((ref _){}(A))); artur That looks

Re: Region allocator strage error

2016-02-01 Thread mark_mcs via Digitalmars-d-learn
On Monday, 1 February 2016 at 12:05:53 UTC, ref2401 wrote: On Sunday, 31 January 2016 at 14:48:34 UTC, ref2401 wrote: I am getting runtime error: core.exception.AssertError@std\experimental\allocator\building_blocks\region.d(235): Assertion failure At least tell me can anyone replicate it? R

Re: how do I tell if something is lvalue?

2016-02-01 Thread Meta via Digitalmars-d-learn
On Monday, 1 February 2016 at 18:28:05 UTC, Artur Skawina wrote: On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn wrote: Thanks! I was surprised this is not straightforward. enum isLvalue(alias A) = is(typeof((ref _){}(A))); artur That looks much nicer. It still needs work

Re: Octree implementation?

2016-02-01 Thread Benjamin Thaut via Digitalmars-d-learn
On Monday, 1 February 2016 at 02:56:06 UTC, Tofu Ninja wrote: Just out of curiosity, does anyone have an octree implementation for D laying around? Just looking to save some time. https://github.com/Ingrater/thBase/blob/master/src/thBase/container/octree.d Its a loose octree implementation. T

Re: how do I tell if something is lvalue?

2016-02-01 Thread Artur Skawina via Digitalmars-d-learn
On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn wrote: > Thanks! I was surprised this is not straightforward. enum isLvalue(alias A) = is(typeof((ref _){}(A))); artur

Re: how do I tell if something is lvalue?

2016-02-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/31/16 5:12 PM, Meta wrote: On Sunday, 31 January 2016 at 22:11:45 UTC, Steven Schveighoffer wrote: On 1/31/16 4:48 PM, Meta wrote: This seems to do the trick, although I haven't extensively tested it. There's probably a simpler way but this is the first thing I could come up with that wo

Re: Region allocator strage error

2016-02-01 Thread Marc Schütz via Digitalmars-d-learn
On Monday, 1 February 2016 at 12:05:53 UTC, ref2401 wrote: On Sunday, 31 January 2016 at 14:48:34 UTC, ref2401 wrote: I am getting runtime error: core.exception.AssertError@std\experimental\allocator\building_blocks\region.d(235): Assertion failure At least tell me can anyone replicate it? M

Re: How to set array length for multidimensional static arrays

2016-02-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 01, 2016 13:22:23 Daniel Kozak via Digitalmars-d-learn wrote: > V Mon, 01 Feb 2016 12:19:10 + > Namal via Digitalmars-d-learn > napsáno: > > > On Monday, 1 February 2016 at 12:12:00 UTC, Jonathan M Davis > > wrote: > > > On Monday, February 01, 2016 11:15:40 Namal via > >

Re: How to set array length for multidimensional static arrays

2016-02-01 Thread Daniel Kozak via Digitalmars-d-learn
V Mon, 01 Feb 2016 12:19:10 + Namal via Digitalmars-d-learn napsáno: > On Monday, 1 February 2016 at 12:12:00 UTC, Jonathan M Davis > wrote: > > On Monday, February 01, 2016 11:15:40 Namal via > > Digitalmars-d-learn wrote: > >> Sorry guys that I didn't express myself well. I also mixed

Re: How to set array length for multidimensional static arrays

2016-02-01 Thread Namal via Digitalmars-d-learn
On Monday, 1 February 2016 at 12:12:00 UTC, Jonathan M Davis wrote: On Monday, February 01, 2016 11:15:40 Namal via Digitalmars-d-learn wrote: Sorry guys that I didn't express myself well. I also mixed some stuff up. What I wanted to ask is this, in c++ this is valid int x = 3; int y = 10

Re: How to set array length for multidimensional static arrays

2016-02-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 01, 2016 11:15:40 Namal via Digitalmars-d-learn wrote: > Sorry guys that I didn't express myself well. I also mixed some > stuff up. What I wanted to ask is this, in c++ this is valid > > int x = 3; > int y = 10; > int arr [x][y]; > > x,y are known at the compile time and

Re: Region allocator strage error

2016-02-01 Thread ref2401 via Digitalmars-d-learn
On Sunday, 31 January 2016 at 14:48:34 UTC, ref2401 wrote: I am getting runtime error: core.exception.AssertError@std\experimental\allocator\building_blocks\region.d(235): Assertion failure At least tell me can anyone replicate it?

Re: How to set array length for multidimensional static arrays

2016-02-01 Thread Daniel Kozak via Digitalmars-d-learn
V Mon, 01 Feb 2016 11:15:40 + Namal via Digitalmars-d-learn napsáno: > Sorry guys that I didn't express myself well. I also mixed some > stuff up. What I wanted to ask is this, in c++ this is valid > > int x = 3; > int y = 10; > int arr [x][y]; > > x,y are known at the co

Re: How to set array length for multidimensional static arrays

2016-02-01 Thread Namal via Digitalmars-d-learn
Sorry guys that I didn't express myself well. I also mixed some stuff up. What I wanted to ask is this, in c++ this is valid int x = 3; int y = 10; int arr [x][y]; x,y are known at the compile time and arr is a static array. I can't do that in D so what is the best way

Re: How to set array length for multidimensional static arrays

2016-02-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 01, 2016 07:42:56 Namal via Digitalmars-d-learn wrote: > On Monday, 1 February 2016 at 07:41:33 UTC, Namal wrote: > > I understand that I cannot pass a variable to the static array > > like in C++, and have to use dynamic arrays. But how can I set > > the length for them without

Re: C Macro deeper meaning?

2016-02-01 Thread Kagamin via Digitalmars-d-learn
On Sunday, 31 January 2016 at 02:58:28 UTC, Andrew Edwards wrote: void notUsed(T)(T v) { return cast(void)0; }; since it always returns cast(void)0 regardless of the input. But it cannot be that simple, so what am I missing? Now notUsed has an unused parameter v.