Template class with dispatched properties

2013-11-07 Thread Ross Hays
;` or something like that. I have tried using @property and the opDispatch method together, but that does not compile. I know I can just use array indicies to access components, but first I wanted to see if this was possible. Any suggestions? Thank you, Ross Hays

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
Awesome that seems to do what I was going for. I had tried a similar approach with @property dispatch and the subtraction of 'x', but I had left out the static if and had the opDispatch returning a ref of the entry in the array (so there would just be the one @property still) but that resulted

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
I am actually a little curious why my original approach did not work at all. Using some of what you provided and some of what I had I get the following: import std.stdio; import std.string; class Vector(int N, T) if (N = 3) { T[N] data; this() { data[] = 0; }

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
Strange. I'm getting a different error, but I'm still running 2.063.2. The error I get is `Error: cannot resolve type for t.opDispatch!(x)` What version are you running? I just updated to 2.064.2 In any case, the reason apparently is multifold: 1. Apparently the proper error message isn't

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
On Friday, 8 November 2013 at 04:28:31 UTC, Ross Hays wrote: Strange. I'm getting a different error, but I'm still running 2.063.2. The error I get is `Error: cannot resolve type for t.opDispatch!(x)` What version are you running? I just updated to 2.064.2 In any case, the reason apparently

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
Sorry, I forgot to mention in that post that you have toOffset in your template constraint, which means it will also never match. You'll have to define it or replace it with `fieldName[0] - 'x';` Also, you might not want to do `fieldName[0 .. 1]` because that's a slice (which is just another

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
Boom, that last few were the issues. I elected to just move the return for the setter onto a separate line, mostly because the idea of auto returning different types seem foreign to me... I have used auto plenty in C++11, but never like that and it just throws me off. But fixing those other

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
Okay here is something I was hoping for some general clarification on related to this and maybe you can help me sort some things out. The opDispatch method has a template parameter of string fieldName. In C++, templates are actually compiled so each different use of a template class is

Re: Ensuring template argument is descendant of class

2013-12-12 Thread Ross Hays
On Thursday, 12 December 2013 at 21:53:20 UTC, Adam D. Ruppe wrote: On Thursday, 12 December 2013 at 21:51:14 UTC, Ross Hays wrote: if (cast(Asset)T) Try this instead: if(is(T : Asset)) the is thing checks types. You can do is(T == Asset) for the specific class, or is(T : Asset

Re: Ensuring template argument is descendant of class

2013-12-12 Thread Ross Hays
Yeah, is-expression syntax is one of the dark, ugly corners of D that unfortunately we're stuck with, because changing it now will totally break a LOT of code for merely cosmetic reasons. I honestly wish that one day this mess could be cleared up, though I'm not holding my breath for it. T

Re: Ensuring template argument is descendant of class

2013-12-12 Thread Ross Hays
I remember seeing some posts about D and how the way it sounded was that D kind of filled the role of C++, without all the burden of years of full backwards comparability. I wouldn't dare say it is that bad, but this is how the problem starts I feel. I would love to see a release cycle like

Access violation error using Derelict GL3

2013-12-15 Thread Ross Hays
I have run into a problem using the Derelict GL3 binding and I am not sure if I am doing something wrong or if this is a bug. I have a class that contains several uints that are to represent the ids returned by OpenGL functions. I have a call to glDeleteBuffers that always result in

Re: Access violation error using Derelict GL3

2013-12-15 Thread Ross Hays
On Sunday, 15 December 2013 at 21:31:21 UTC, Andrej Mitrovic wrote: On 12/15/13, Ross Hays t...@gmail.com wrote: Am I doing something wrong here? You're likely not loading the function pointers first. Try calling DerelictGL.reload() first. That was it... knew it was something dumb. I had

Why does this template constraint not work?

2013-12-27 Thread Ross Hays
import std.stdio; void test(T)() if (is (T : float)) { writeln(typeid(T)); } void main() { test!int; } When I run this I am getting the output int My understanding of template constraints is that the call to test!int will not find a match since the function test only

Re: Why does this template constraint not work?

2013-12-27 Thread Ross Hays
On Saturday, 28 December 2013 at 02:27:00 UTC, Ross Hays wrote: import std.stdio; void test(T)() if (is (T : float)) { writeln(typeid(T)); } void main() { test!int; } When I run this I am getting the output int My understanding of template constraints is that the call

Re: Why does this template constraint not work?

2013-12-27 Thread Ross Hays
If you want to accept any floating point type but not implicit conversions, then use std.traits.isFloatingPoint. Thank you that's good to know. Though for this particular example I was just making a basic demo of the problem.

Documenting contracts in Ddoc

2014-01-01 Thread Ross Hays
Given that D has contracts built into the language (which is one of my favorite features of D by far) it seems to me that it should be possible to document the pre and post conditions of a contract using a contract section in Ddoc. I have been reading through the documentation on Ddoc to see

Thread Building Blocks

2014-01-09 Thread Ross Hays
Does anybody know if there is a library like thread building blocks for D? I imagine that it hasn't been ported or anything given it is a C++ library and licensed inconveniently. If not, is there something in Phobos similar to it or that would help in making it? I may try writing something

Re: Thread Building Blocks

2014-01-19 Thread Ross Hays
It seems to be somewhat similar to std.parallelism (http://dlang.org/phobos/std_parallelism.html) I have seen that before, didn't know if there was anything closer with the task scheduler and worker threads described in the documentation for TBB, or if that was the closest thing. I see that