how to sort the container Array from std.container

2018-06-06 Thread Flaze07 via Digitalmars-d-learn
I know that sort accepts Range( I am correct right ? ), so, Array!uint arr; //inserts element to arr sort( arr.Range ); don't work, it says cannot pass RangeT!(Array!uint) as function argument

remove not callable for char[]

2018-06-12 Thread Flaze07 via Digitalmars-d-learn
well, not really, it just cannot auto deduce, the problem is, I don't know what to put in, I know that I can put in SwapStrategy.stable for the first one, but what about the Range, I don't know what to put in E.g int[] i = [ 1, 2 ]; i = i.remove( 1 );//able to automagically deduce char[] c =

Re: how to sort the container Array from std.container

2018-06-08 Thread Flaze07 via Digitalmars-d-learn
On Wednesday, 6 June 2018 at 14:46:56 UTC, ag0aep6g wrote: On 06/06/2018 04:20 PM, Flaze07 wrote: hmm, and sorry for asking more, what about removing an element from it ? I found no remove operation that can remove from the middle ( removeAny and removeBack both removes the latest element,

Re: remove not callable for char[]

2018-06-12 Thread Flaze07 via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:08:25 UTC, Steven Schveighoffer wrote: On 6/12/18 2:33 AM, Flaze07 wrote: well, not really, it just cannot auto deduce, the problem is, I don't know what to put in, I know that I can put in SwapStrategy.stable for the first one, but what about the Range, I don't

Re: how to sort the container Array from std.container

2018-06-06 Thread Flaze07 via Digitalmars-d-learn
On Wednesday, 6 June 2018 at 14:06:54 UTC, rikki cattermole wrote: On 07/06/2018 1:58 AM, Flaze07 wrote: On Wednesday, 6 June 2018 at 13:46:41 UTC, Adam D. Ruppe wrote: On Wednesday, 6 June 2018 at 13:44:09 UTC, Flaze07 wrote: sort( arr.Range ); don't work, it says cannot pass

Re: how to sort the container Array from std.container

2018-06-06 Thread Flaze07 via Digitalmars-d-learn
On Wednesday, 6 June 2018 at 13:46:41 UTC, Adam D. Ruppe wrote: On Wednesday, 6 June 2018 at 13:44:09 UTC, Flaze07 wrote: sort( arr.Range ); don't work, it says cannot pass RangeT!(Array!uint) as function argument Range is the type, you want the value I think you can do sort(arr[]) maybe

Re: how to sort the container Array from std.container

2018-06-06 Thread Flaze07 via Digitalmars-d-learn
On Wednesday, 6 June 2018 at 14:24:15 UTC, rikki cattermole wrote: On 07/06/2018 2:20 AM, Flaze07 wrote: On Wednesday, 6 June 2018 at 14:06:54 UTC, rikki cattermole wrote: On 07/06/2018 1:58 AM, Flaze07 wrote: [...] Yes. hmm, and sorry for asking more, what about removing an element from

Re: how to sort the container Array from std.container

2018-06-06 Thread Flaze07 via Digitalmars-d-learn
On Wednesday, 6 June 2018 at 14:29:28 UTC, rikki cattermole wrote: On 07/06/2018 2:27 AM, Flaze07 wrote: On Wednesday, 6 June 2018 at 14:24:15 UTC, rikki cattermole wrote: On 07/06/2018 2:20 AM, Flaze07 wrote: On Wednesday, 6 June 2018 at 14:06:54 UTC, rikki cattermole wrote: [...] hmm,

what is the point of functor ?

2018-06-22 Thread Flaze07 via Digitalmars-d-learn
recently, I visited the glossary and saw that functor exist in D...I know that functor exist C++ as a way to easily allow higher order function, but since D already has function and delegates, is there a point to functor ?

Re: using tuple as value type for associative array

2018-06-20 Thread Flaze07 via Digitalmars-d-learn
On Thursday, 21 June 2018 at 03:04:46 UTC, Computermatronic wrote: On Thursday, 21 June 2018 at 02:44:12 UTC, Flaze07 wrote: when I do Tuple!(uint, "first", uint, "second")[string] what; //I tried aliasing the tuple as well what["something"].first = 20; I get range error but when I do

using tuple as value type for associative array

2018-06-20 Thread Flaze07 via Digitalmars-d-learn
when I do Tuple!(uint, "first", uint, "second")[string] what; //I tried aliasing the tuple as well what["something"].first = 20; I get range error but when I do uint[string] what2; what2 = 20; I get none of those range error, so...how do I use tuple as value type for associative array ?

how to create an array of scoped objects ?

2018-07-02 Thread Flaze07 via Digitalmars-d-learn
e.g A is a class that emits output during destruction { auto a = scoped!A(); } how do I contain it in a container, in the Array struct ? { auto a = scoped!A(); Array!( typeof( a ) ) arr; foreach( i ; 0..3 ) { arr.insertBack( scoped!A ); } } is that how you do it ?

Re: how to create an array of scoped objects ?

2018-07-03 Thread Flaze07 via Digitalmars-d-learn
On Tuesday, 3 July 2018 at 07:03:43 UTC, vit wrote: On Tuesday, 3 July 2018 at 02:13:21 UTC, Flaze07 wrote: e.g A is a class that emits output during destruction { auto a = scoped!A(); } how do I contain it in a container, in the Array struct ? { auto a = scoped!A(); Array!(

Re: how to create an array of scoped objects ?

2018-07-03 Thread Flaze07 via Digitalmars-d-learn
On Tuesday, 3 July 2018 at 10:00:00 UTC, Mike Parker wrote: The only way you're going to be leaking resources is if the app is long running and the resource objects are never collected. I'd be more concerned about the nondeterministic nature of the destructor calls, particularly what happens

Re: how to create an array of scoped objects ?

2018-07-03 Thread Flaze07 via Digitalmars-d-learn
On Tuesday, 3 July 2018 at 14:32:01 UTC, Mike Parker wrote: Resources allocated for the process will be released on exit. I see...but it is dependant on the OS right ? because I have seen other stuff relating to malloc as well, there are some out there that said that there is no need to

how to build DSFMLC ?

2018-08-19 Thread Flaze07 via Digitalmars-d-learn
I keep having the same problem with building DSFMLC https://ibb.co/edRStK

Re: how to build DSFMLC ?

2018-08-24 Thread Flaze07 via Digitalmars-d-learn
On Sunday, 19 August 2018 at 08:57:05 UTC, Flaze07 wrote: I keep having the same problem with building DSFMLC https://ibb.co/edRStK for anyone having the same problem, I found the solution in another thread. You have to use MinGW32 bit version if you use mingw, as for visual C++, I think

Re: how to compile D programs without console window

2018-07-14 Thread Flaze07 via Digitalmars-d-learn
On Sunday, 15 July 2018 at 01:20:25 UTC, evilrat wrote: ... "lflags": [ "/SUBSYSTEM:windows" ], ... didn't know that, thank you

Re: how to compile D programs without console window

2018-07-14 Thread Flaze07 via Digitalmars-d-learn
On Saturday, 14 July 2018 at 09:39:21 UTC, rikki cattermole wrote: If you're using dub, throw them into lflags and remove the -L. https://forum.dlang.org/post/gmcsxgfsfnwllploo...@forum.dlang.org hmm, for some unknown reason it says that it is unable to find SUBSYSTEM:windows.lib

how to compile D programs without console window

2018-07-14 Thread Flaze07 via Digitalmars-d-learn
how do you compile a D programs without a console window ? I found this link https://wiki.dlang.org/D_for_Win32 I know that you need .def file, but how do you link to .def ?

how to import file from another path in dub ?

2018-07-04 Thread Flaze07 via Digitalmars-d-learn
I have a dub project, and I put the importPath to the path of the file I want to import and the source file to the source folder, and it appears that I have succeeded at importing the module, but there's one problem, it appears like I need to define some sort of thing, because the error says "

Re: Cleanup class after method?

2018-07-04 Thread Flaze07 via Digitalmars-d-learn
On Wednesday, 4 July 2018 at 16:02:25 UTC, Jonathan M Davis wrote: -dip1000 fully implements scope so that it verifies that no reference escapes, but it's not ready yet, let alone the default behavior. - Jonathan M Davis I read the proposal about -dip1000 ( not all, some ) and there is

Re: how to import file from another path in dub ?

2018-07-05 Thread Flaze07 via Digitalmars-d-learn
On Thursday, 5 July 2018 at 08:55:13 UTC, Timoses wrote: Depending on your use case I see these options: - If you have a library that defines the symbols that you are using in the imported files you could use the dub `libs` setting - Otherwise, if you're just using the other folder to separate

how to link self made lib using dub

2018-07-06 Thread Flaze07 via Digitalmars-d-learn
I have been trying to link self made .lib, and have tried to use it several times, I failed.. so, here I have a file in this path : Z:\programming\D\usefulFiles\experiment\source\output.d it has module output; class Output { public: static void write( string msg ) { import

Re: how to link self made lib using dub

2018-07-06 Thread Flaze07 via Digitalmars-d-learn
On Friday, 6 July 2018 at 21:13:37 UTC, Timoses wrote: Shouldn't this be 'import output'? nah, because I didn't import source directly, I import experiment so in order to use it, I do source/output.d, which when importing module means, source.output and this '...\\experiment\\source\\'? (I'm

Re: Outside array bounds

2018-07-07 Thread Flaze07 via Digitalmars-d-learn
On Saturday, 7 July 2018 at 08:09:51 UTC, vino.B wrote: Hi All, Request you help, on the below code import std.stdio: writeln; void process(T ...)(string ID, T args) { if (ID == "I1") { writeln(args.length, "\t", args[0]); } else if (ID == "I2") { writeln(args.length, "\t", args[1]);} }

how to do template constraints with variadic templates ?

2018-07-07 Thread Flaze07 via Digitalmars-d-learn
I want to force the variadic templates's type to be of certain types, I thought doing this would work auto sum( A... )( A a ) if( isIntegral!( typeid( a[ 0 ] ) ) ) { int temp; foreach( t ; a ) { temp += t; } return temp; } but it gives out error ( note : I want all

Re: how to do template constraints with variadic templates ?

2018-07-07 Thread Flaze07 via Digitalmars-d-learn
On Sunday, 8 July 2018 at 00:46:13 UTC, Flaze07 wrote: I want to force the variadic templates's type to be of certain types, I thought doing this would work auto sum( A... )( A a ) if( isIntegral!( typeid( a[ 0 ] ) ) ) { int temp; foreach( t ; a ) { temp += t; }

Re: how to do template constraints with variadic templates ?

2018-07-07 Thread Flaze07 via Digitalmars-d-learn
On Sunday, 8 July 2018 at 02:10:12 UTC, Simen Kjærås wrote: Also, you should probably use CommonType!A for the type of temp, since an int can't hold all the possible values of a long or ulong (or even uint), and you'll thus get unexpected results with large numbers. -- Simen I see, thanks,

Re: class that is initialized becomes null when outside of function

2018-07-09 Thread Flaze07 via Digitalmars-d-learn
On Monday, 9 July 2018 at 09:18:50 UTC, Flaze07 wrote: I am using DSFML module game; [...] oh, and I forgot, I had Game myGame; static this() { myGame = new Game; } below the Game class

class that is initialized becomes null when outside of function

2018-07-09 Thread Flaze07 via Digitalmars-d-learn
I am using DSFML module game; import core.time; import std.stdio: writeln; import dsfml.graphics; import dsfgui.button; import apple; import snake; class Game { private: enum State { menu, playing } State state; Font font; Button playBtn; Snake snake; Apple apple;

Re: class that is initialized becomes null when outside of function

2018-07-09 Thread Flaze07 via Digitalmars-d-learn
On Monday, 9 July 2018 at 09:38:30 UTC, ag0aep6g wrote: The `win` you're creating in `init` is a function-local variable. It ceases to exist when `init` returns. It's not `this.win`. In `run`, you're accessing `this.win`. It's still null because you never assigned anything there. So change

Re: how to create an array of scoped objects ?

2018-07-03 Thread Flaze07 via Digitalmars-d-learn
On Tuesday, 3 July 2018 at 15:06:28 UTC, Mike Parker wrote: .. That said, the GC in D runs when main exits anyway, so the destructor in your example will be called. That's why I warned earlier about it being nondeterministic. For example, if you have a Texture instance that depends on the

Re: what is the point of functor ?

2018-06-24 Thread Flaze07 via Digitalmars-d-learn
On Friday, 22 June 2018 at 20:20:56 UTC, Steven Schveighoffer wrote: On 6/22/18 2:25 PM, Ali Çehreli wrote: On 06/22/2018 08:17 AM, Steven Schveighoffer wrote: > reason to use functors I wonder whether they are more efficient because a functor would carry just the state that it needs. Also,

Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn
On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote: On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote: is there some sort of ways to turn range into tuple ? ( an array preferably ) e.g uint[] arr = [ 10, 20, 30 ]; auto tup = rangeToTup( arr ); assert( tup[ 0 ] == 10 );

Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn
On Thursday, 28 June 2018 at 09:47:07 UTC, Jonathan M Davis wrote: On Thursday, June 28, 2018 09:26:10 Flaze07 via Digitalmars-d-learn wrote: On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote: > [...] what about during runtime ? Ranges in general have an arbitrary len

Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn
On Thursday, 28 June 2018 at 09:42:54 UTC, Flaze07 wrote: On Thursday, 28 June 2018 at 09:38:36 UTC, Stefan Koch wrote: On Thursday, 28 June 2018 at 09:26:10 UTC, Flaze07 wrote: On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote: On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07

Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn
On Thursday, 28 June 2018 at 09:38:36 UTC, Stefan Koch wrote: On Thursday, 28 June 2018 at 09:26:10 UTC, Flaze07 wrote: On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote: On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote: is there some sort of ways to turn range into tuple ?

turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn
is there some sort of ways to turn range into tuple ? ( an array preferably ) e.g uint[] arr = [ 10, 20, 30 ]; auto tup = rangeToTup( arr ); assert( tup[ 0 ] == 10 ); assert( tup[ 1 ] == 20 ); assert( tup[ 2 ] == 30 );