Re: Using private constructor with std.experimental.allocater:make

2016-05-01 Thread earthfront via Digitalmars-d-learn
On Sunday, 1 May 2016 at 19:18:38 UTC, Basile B wrote: CT make(CT, Alloc, A...)(auto ref Alloc al, A a) This works. Thank you. Good point about __ctor alone not being sufficient. auto memory = al.allocate(size); ... GC.addRange(memory.ptr, size, typeid(CT)); Nit:

Re: Using private constructor with std.experimental.allocater:make

2016-05-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Sun, 01 May 2016 18:27:51 + Lass Safin via Digitalmars-d-learn wrote: > On Sunday, 1 May 2016 at 11:17:27 UTC, earthfront wrote: > > Hello! > > [...] > > class A > >{ int b; private this(int a){b=a;} } > > [...] > > I don't think classes are

simple idea for error messages

2016-05-01 Thread Laeeth Isharc via Digitalmars-d-learn
when it cannot match a prototype eg: module foo; enum Foo { foo } void bar(Foo foo) { } module bar; enum Foo { foo } void fooBar(Foo foo) { bar(foo); } rather than complain the type X does not match the type X - an unhelpful message - could the compiler not check to see if the type

Re: Can't use std.algorithm.remove on a char[]?

2016-05-01 Thread TheGag96 via Digitalmars-d-learn
On Sunday, 1 May 2016 at 09:11:22 UTC, ag0aep6g wrote: It's because of auto-decoding. char[] is an array of chars, but it's been made a range of dchars. Calling front on a char[] decodes up to four chars into one dchar. Obviously you can't take the address of the dchar, because it's just a

Re: Using private constructor with std.experimental.allocater:make

2016-05-01 Thread Basile B via Digitalmars-d-learn
On Sunday, 1 May 2016 at 11:17:27 UTC, earthfront wrote: Hello! This code fails: - void main(){ class A { int b; private this(int a){b=a;} } //{ int b; this(int a){b=a;} } import std.conv:emplace; import std.experimental.allocator.mallocator:Mallocator; import

Re: Using private constructor with std.experimental.allocater:make

2016-05-01 Thread Lass Safin via Digitalmars-d-learn
On Sunday, 1 May 2016 at 11:17:27 UTC, earthfront wrote: Hello! [...] class A { int b; private this(int a){b=a;} } [...] I don't think classes are supposed to be able to have a private constructor...

Re: Using a string generated at compile-time in a @nogc function

2016-05-01 Thread Basile B via Digitalmars-d-learn
On Sunday, 1 May 2016 at 13:22:27 UTC, Mithun Hunsur wrote: On Sunday, 1 May 2016 at 10:37:23 UTC, Anonymouse wrote: On Sunday, 1 May 2016 at 05:28:36 UTC, Mithun Hunsur wrote: Hi all, I'm working on removing the string mixins from my code, but have run into an issue:

Re: Method doesn't compile when defined in a mixin, but is fine without?

2016-05-01 Thread pineapple via Digitalmars-d-learn
On Sunday, 1 May 2016 at 13:46:14 UTC, ag0aep6g wrote: On 01.05.2016 15:32, pineapple wrote: static string vectorpropertymixin(string name, string SDL_getter, string SDL_setter){ [...] mixin(vectorpropertymixin( "minsize", "SDL_GetWindowMinimumSize", "SDL_GetWindowMinimumSize" ));

Re: Method doesn't compile when defined in a mixin, but is fine without?

2016-05-01 Thread ag0aep6g via Digitalmars-d-learn
On 01.05.2016 15:32, pineapple wrote: static string vectorpropertymixin(string name, string SDL_getter, string SDL_setter){ [...] mixin(vectorpropertymixin( "minsize", "SDL_GetWindowMinimumSize", "SDL_GetWindowMinimumSize" )); Should the second one be "SDL_SetWindowMinimumSize" here?

Re: Method doesn't compile when defined in a mixin, but is fine without?

2016-05-01 Thread pineapple via Digitalmars-d-learn
Strangely, though I'm getting this error when wrapping SDL_GetWindowMinimumSize and SDL_GetWindowMaximumSize, I don't get any compilation errors wrapping the identically-signatured SDL_GetWindowSize and SDL_GetWindowPosition using the same mixin.

Method doesn't compile when defined in a mixin, but is fine without?

2016-05-01 Thread pineapple via Digitalmars-d-learn
I'm working on an SDL wrapper based on the derelict sdl2 and opengl3 bindings and so I've got a method like this I wrote: @property Vector2!int minsize(){ int x, y; SDL_GetWindowMinimumSize(this.window, , ); return Vector2!int(x, y); } I've got several almost identical methods for

Re: Using a string generated at compile-time in a @nogc function

2016-05-01 Thread Mithun Hunsur via Digitalmars-d-learn
On Sunday, 1 May 2016 at 10:37:23 UTC, Anonymouse wrote: On Sunday, 1 May 2016 at 05:28:36 UTC, Mithun Hunsur wrote: Hi all, I'm working on removing the string mixins from my code, but have run into an issue: http://dpaste.dzfl.pl/ecd7eb53947e As far as I can tell, this should work; the

Cannot link daimos glfw using x64

2016-05-01 Thread ParticlePeter via Digitalmars-d-learn
I am failing to link statically to glfw library with deimos glfw. The repo includes an example for glfw2. I downloaded the latest glfw2.lib and tried build the example with -m64 and got these errors: C:\ ... \deimos-glfw>dmd GLFW.lib examples/glfw2/openwindow/openwindow.d -m64

Using private constructor with std.experimental.allocater:make

2016-05-01 Thread earthfront via Digitalmars-d-learn
Hello! This code fails: - void main(){ class A { int b; private this(int a){b=a;} } //{ int b; this(int a){b=a;} } import std.conv:emplace; import std.experimental.allocator.mallocator:Mallocator; import std.experimental.allocator:make; { auto ptr =

Re: Setting a list of values

2016-05-01 Thread Marc Schütz via Digitalmars-d-learn
On Sunday, 1 May 2016 at 05:42:00 UTC, Ali Çehreli wrote: On 04/30/2016 10:05 PM, Joel wrote: > This has no effect: > _bars.each!(a => { a._plots.fillColor = Color(255, 180, 0); }); This is a common issue especially for people who know lambdas from other languages. :) Your lambda does not do

Re: Getting all struct members and values with introspection avoiding string mixins

2016-05-01 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 1 May 2016 at 10:13:47 UTC, H. S. Teoh wrote: On Sun, May 01, 2016 at 09:42:37AM +, ParticlePeter via Digitalmars-d-learn wrote: I am logging arbitrary POD struct types with member names and data: void printStructInfo( T )( T info ) { foreach( i, A; typeof( T.tupleof )) {

Re: Using a string generated at compile-time in a @nogc function

2016-05-01 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 1 May 2016 at 05:28:36 UTC, Mithun Hunsur wrote: Hi all, I'm working on removing the string mixins from my code, but have run into an issue: http://dpaste.dzfl.pl/ecd7eb53947e As far as I can tell, this should work; the enum should force compile-time execution (which it does, as

Re: Using a string generated at compile-time in a @nogc function

2016-05-01 Thread Mithun Hunsur via Digitalmars-d-learn
On Sunday, 1 May 2016 at 08:14:43 UTC, Nicholas Wilson wrote: On Sunday, 1 May 2016 at 05:28:36 UTC, Mithun Hunsur wrote: Hi all, I'm working on removing the string mixins from my code, but have run into an issue: http://dpaste.dzfl.pl/ecd7eb53947e As far as I can tell, this should work;

Re: Getting all struct members and values with introspection avoiding string mixins

2016-05-01 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, May 01, 2016 at 09:42:37AM +, ParticlePeter via Digitalmars-d-learn wrote: > I am logging arbitrary POD struct types with member names and data: > > void printStructInfo( T )( T info ) { > foreach( i, A; typeof( T.tupleof )) { > enum attribName = T.tupleof[i].stringof; >

Getting all struct members and values with introspection avoiding string mixins

2016-05-01 Thread ParticlePeter via Digitalmars-d-learn
I am logging arbitrary POD struct types with member names and data: void printStructInfo( T )( T info ) { foreach( i, A; typeof( T.tupleof )) { enum attribName = T.tupleof[i].stringof; writefln( "%s : %s", attribName, mixin( "info." ~ attribName )); } } Is there is some other way

Re: Can't use std.algorithm.remove on a char[]?

2016-05-01 Thread ag0aep6g via Digitalmars-d-learn
On 01.05.2016 07:29, TheGag96 wrote: Why exactly is it like this? I would understand why strings (immutable character arrays) behave like this, but I feel like plain old character arrays should work the same as an array of ubytes when treated as a range... Or is there some other string-related

Re: Using a string generated at compile-time in a @nogc function

2016-05-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 May 2016 at 05:28:36 UTC, Mithun Hunsur wrote: Hi all, I'm working on removing the string mixins from my code, but have run into an issue: http://dpaste.dzfl.pl/ecd7eb53947e As far as I can tell, this should work; the enum should force compile-time execution (which it does, as