Determining if a class has a template function

2016-10-11 Thread Straivers via Digitalmars-d-learn
I have a class T with a templated function foo(string name)(int, int, float) that will be mixed in via template, and I want to determine if that class has mixed it in such that foo(name = "bar"). How could I go about this? Thanks. eg: mixin template A(string name, Args...) { void foo(stri

Re: How to create dynamically sized objects

2016-09-29 Thread Straivers via Digitalmars-d-learn
Actually, would just passing the parameters and an allocator do it? You'd just need to allocate the string in the constructor, right?

How to create dynamically sized objects

2016-09-29 Thread Straivers via Digitalmars-d-learn
Hi, Say I wanted to create an object that has a string member, and I want the string to be allocated with the object contiguously instead of as a pointer to another location (as a constructor would do). For example: class C { this(int i, string s) { this.i = i; this.s = s

Re: Adding a float with all four elements of a float4

2016-04-20 Thread Straivers via Digitalmars-d-learn
On Thursday, 21 April 2016 at 01:49:19 UTC, Nicholas Wilson wrote: [...] you want to broadcast the rhs to a float4 and then adds them. Can you post the errors (if any) you get during compilation. Urgh, autocorrect. That should be addps them. I get a "Error: floating point constant expressi

Adding a float with all four elements of a float4

2016-04-20 Thread Straivers via Digitalmars-d-learn
Hi, I want to make a utility wrapper around a core.simd.float4, and have been trying to make the following code work, but have been met with no success. auto add(float rhs) { return __simd(XMM.ADDPS, lhs, rhs); } Then I tried auto add(float4 lhs, float rhs) { float4 tmp = [rhs, rhs,

Using the Windows headers with Unicode

2016-01-08 Thread Straivers via Digitalmars-d-learn
So I've been trying to create a window, and have been working my way through the MSDN tutorials. However, I have always had to specifically specify if I was using either the Unicode or ANSI version of a struct or function. Looking through the druntime code (especially winuser.d), it appears tha

Re: Get superclasses at compile time

2016-01-06 Thread Straivers via Digitalmars-d-learn
Huh, alright. Thanks.

Re: Get superclasses at compile time

2016-01-04 Thread Straivers via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 04:41:45 UTC, Rikki Cattermole wrote: On 05/01/16 5:37 PM, Straivers wrote: Hello, I'm working on an event system, and I want to be able to check if an event is a subclass of another event. How might I go about this? In essence, I'm looking to compress this: st

Get superclasses at compile time

2016-01-04 Thread Straivers via Digitalmars-d-learn
Hello, I'm working on an event system, and I want to be able to check if an event is a subclass of another event. How might I go about this? In essence, I'm looking to compress this: static if (E == UserInputEvent || E == MouseEvent || E == MouseButtonEvent || E == MouseReleasedEvent) {

Comparing arrays of floats?

2015-10-09 Thread Straivers via Digitalmars-d-learn
Forgive me if this has already been discussed, but how are arrays of floating point numbers compared in D? i.e. Is it a bit-by-bit comparison, is the std.math.approxEqual function get called for each element, or is it byte-by-byte across the entire array? -Straivers