Re: How to specify an exact template?

2021-01-16 Thread solidstate1991 via Digitalmars-d-learn
Well, it's quite complicated to do. I have to manually unwrap each and all function template, then pray for the compile-time optimization gods that they'll be inlined. This is so annoying, that I might issue a DIP...

Re: How to specify an exact template?

2021-01-16 Thread solidstate1991 via Digitalmars-d-learn
On Saturday, 16 January 2021 at 14:18:55 UTC, Tove wrote: probably you can use https://dlang.org/spec/traits.html#getOverloads I don't know how to use it with functions outside of structs/classes.

Re: How to specify an exact template?

2021-01-16 Thread solidstate1991 via Digitalmars-d-learn
On Saturday, 16 January 2021 at 14:13:29 UTC, solidstate1991 wrote: Here's the following line, among many others: return !(ubyte); This generates an error, as this function template matches two instances, but currently I don't know how to choose the one I need, other than write a local

How to specify an exact template?

2021-01-16 Thread solidstate1991 via Digitalmars-d-learn
Here's the following line, among many others: return !(ubyte); This generates an error, as this function template matches two instances, but currently I don't know how to choose the one I need, other than write a local function, that looks a bit ugly.

Re: opApply and attributes

2020-07-16 Thread solidstate1991 via Digitalmars-d-learn
On Tuesday, 14 July 2020 at 00:17:14 UTC, solidstate1991 wrote: Something like that, but with @safe, pure, etc. attributes. I've tried to "bruteforce" it by generating functions with combinations of attributes, and it kinda works, but is a very janky solution. I'll brainstorm some DIP to

Re: opApply and attributes

2020-07-13 Thread solidstate1991 via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 20:53:05 UTC, Ali Çehreli wrote: I am not sure whether I understand it correctly but there has been a request for opApply() to gain the attributes of the delegate (or the range?). In other words, "transfer the attributes to opApply". This is needed because I want

Re: opApply and attributes

2020-07-07 Thread solidstate1991 via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 13:33:41 UTC, Paul Backus wrote: You can make opApply a template: int opApply(Dg)(Dg dg) if (is(Dg : scope int delegate(ref E))) { // etc. } Because `scope int delegate(ref E) @safe` implicitly converts to `scope int delegate(ref E)`,

opApply and attributes

2020-07-06 Thread solidstate1991 via Digitalmars-d-learn
See implementation of data structure here: https://github.com/ZILtoid1991/collections-d/blob/master/source/collections/treemap.d#L565 If I try to compile this code, it'll fail, limiting it's usecase: @safe pure unittest { alias IntMap = TreeMap!(int, int, false); IntMap test;

Re: A custom name for variables

2020-05-29 Thread solidstate1991 via Digitalmars-d-learn
On Thursday, 28 May 2020 at 20:26:55 UTC, Quantium wrote: I need to create a variable with custom name, like this import std; void main() { string name; readf(" %s", ); // some code that generates a variable of type integer and value 0 } Could you help me with that? This might be

Re: Linker error under Ubuntu

2020-05-15 Thread solidstate1991 via Digitalmars-d-learn
On Friday, 15 May 2020 at 03:46:57 UTC, evilrat wrote: Um, pardon the stupid question, but did you just forgot to link it? I can't see a mention of it anywhere in both the old json and dub.sdl, and I don't see subpackages either. (does it links implicitly by the compiler?) Also if it's

Linker error under Ubuntu

2020-05-14 Thread solidstate1991 via Digitalmars-d-learn
When I try to compile my own project under Ubuntu with dub, I get the following linker error: /usr/bin/ld: .dub/obj/pixelperfectengine_pixelperfecteditor.o: undefined reference to symbol 'inflateEnd' //lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line

Re: Fixing race issues the right way

2020-04-20 Thread solidstate1991 via Digitalmars-d-learn
On Sunday, 5 April 2020 at 22:33:50 UTC, Stefan Koch wrote: Look at your program in a debugger and see if it does spawn threads. If it does find out where and why they are spawned. Thanks for the answer, but it seems the issue was the lack of the ability of unittesting such a large

Fixing race issues the right way

2020-04-05 Thread solidstate1991 via Digitalmars-d-learn
My game engine is currently broken due to some race issue I don't really know how to resolve. It seems that the compiler tries to skip instructions that are not locked with a `writeln()` or something similar. Usually I can safely remove the writeln after compiling it once with that way.

Re: How to debug in vscode Windows?

2020-01-01 Thread solidstate1991 via Digitalmars-d-learn
On Wednesday, 1 January 2020 at 14:46:01 UTC, NaN wrote: You can use visual studio (works in 2019, havent tried earlier versions) to debug any exe you want. You do this... Go to File menu, then Open, then Project/Solution Make sure "all project files" is selected, then find the exe you want

LLD-link doesn't work, how do I change linkers?

2020-01-01 Thread solidstate1991 via Digitalmars-d-learn
I cannot do any work, since LLD-link is broken and doesn't want to link for anything. It just gives me a bunch of errors for missing symbols, that supposed to be in the core libraries. How can I set up the Microsoft linker instead?

"Mixin is not defined" error when trying to use template mixins

2019-10-27 Thread solidstate1991 via Digitalmars-d-learn
There's a template mixin in my dimage project's new version in base.d, and when I try to access it from another file I get two errors: undefined identifier `ChunkyAccess4bit`, did you mean template `ChunkyAccess4Bit()`? and mixin `dimage.tga.TGA.ChunkyAccess4bit!()` is not defined Should

Any easy way to check if an object have inherited an interface?

2019-07-22 Thread solidstate1991 via Digitalmars-d-learn
It seems that I've to write my own function that searches in the given object's classinfo.interfaces since I couldn't find anything related in Phobos.

Re: std.zlib odd behavior

2019-05-20 Thread solidstate1991 via Digitalmars-d-learn
On Wednesday, 6 March 2019 at 01:50:16 UTC, solidstate1991 wrote: Thanks, it seems I'll have to write my own solution for this, and I really dislike the way streaming compression works in C. I've spotted some other bugs regarding my PNG implementation, but those were unrelated and didn't

Re: std.zlib odd behavior

2019-03-05 Thread solidstate1991 via Digitalmars-d-learn
On Tuesday, 5 March 2019 at 02:19:26 UTC, Adam D. Ruppe wrote: I haven't found the bug in your code yet, but one thing I suspect from my experience is you might be reusing a buffer. std.zlib actually stores pointers internally across function calls, so if you are trying to compress a stream,

std.zlib odd behavior

2019-03-04 Thread solidstate1991 via Digitalmars-d-learn
https://github.com/ZILtoid1991/dimage/blob/master/source/dimage/png.d It seems that after a certain point, it doesn't add more data to the compression stream, flushing doesn't help.

Re: Odd behavior of darray.dup

2019-02-23 Thread solidstate1991 via Digitalmars-d-learn
On Saturday, 23 February 2019 at 19:21:10 UTC, Bastiaan Veelo wrote: It works for me: https://run.dlang.io/gist/473b0021487275751accaebeb00be05c -- Bastiaan Still no luck, not even with memcpy. There's even more mystery as I printed out the original static immutable array's content, which

Odd behavior of darray.dup

2019-02-22 Thread solidstate1991 via Digitalmars-d-learn
If I want to copy an array of structs with .dup (cannot post the link in question here at the moment due to non-working clipboard, it's Color from pixelperfectengine.graphics.common) I get all zeroes instead of the values from the original array. I haven't disabled post-blit to my knowledge.

Where to start with SafeD?

2019-02-13 Thread solidstate1991 via Digitalmars-d-learn
When I tried to apply to a position at Symmetry, I've got a criticism from Atila Neves that some of my code relied too much on memcpy, thus making it unsafe. After digging into std.array, I found some function that could possibly replace it to emulate writing in the middle of a file, but at

Should this library binding work?

2018-12-26 Thread solidstate1991 via Digitalmars-d-learn
https://github.com/ZILtoid1991/bindbc-zstandard After looking for alternatives to my megaproject of porting LZHAM to D (since it had several issues, I'll salvaging my tar implementation as well as another archive format meant for application data storage), I found out that zstandard not only

Template matches more than one template declaration error when trying to pass function's pointer

2018-11-30 Thread solidstate1991 via Digitalmars-d-learn
After some refactoring, there are four functions sharing the same name (technically four, but LDC didn't complain about them): @nogc void blitter(T)(T* src, T* dest, size_t length){...} and @nogc void blitter(T)(T* src, T* dest, size_t length, T* mask){...} I need the first one, but at

Can opApply be made @nogc?

2018-10-19 Thread solidstate1991 via Digitalmars-d-learn
Since it's a bit difficult to make tree traversal through range (especially if someone wants to make it @nogc), I thought I'll make it through opApply override, however the delegate passed by it doesn't have the @nogc attribute, which would automatically make it incapable to be used in a @nogc

Interfacing D with C++ functions that take reference values

2018-10-03 Thread solidstate1991 via Digitalmars-d-learn
I need some C++ stuff, but some of the functions take reference values (Stuff&), and I don't know if this feature is emulated on D side with extern(C++) functions. While I don't have to worry about it with functions that are defined in the header, other ones and classes are a different matter.

Using fibers

2018-08-03 Thread solidstate1991 via Digitalmars-d-learn
I'm porting LZHAM to D, and the original used some very unusual approach for coroutines: - the whole thing is running inside of a single switch-case block created by C++ macros - the function saves some local values - a macro sets the state variable to the current line number, returns the

Casting a pointer and length value as a dynamic array

2018-07-30 Thread solidstate1991 via Digitalmars-d-learn
I need this to port a C++ code to D (a compression algorithm known as LZHAM), and the easiest way to deal with it would be that. The ADLER32 and CRC32 algorithms had to be ditched, and while I could rewrite the former to make sense (used some form of "vectorization") I would like to use the

Re: Using an external Assembler with D

2018-04-25 Thread solidstate1991 via Digitalmars-d-learn
On Wednesday, 25 April 2018 at 15:25:42 UTC, Stefan Koch wrote: Pass stuff on the stack ;) and use extern (C) functions. Thanks! What about extern (D)? Is there a big chaos in the D ABI under x86?

Using an external Assembler with D

2018-04-24 Thread solidstate1991 via Digitalmars-d-learn
In order to make one of my own code more readable (and hopefully to avoid a lot of compiling errors under LDC, which don't happen in DMD for some reason), I'm planning to put my assembly functions into separate files for each system that needs them, mainly due to the lack of proper SIMD

Better multithreading with D

2018-04-20 Thread solidstate1991 via Digitalmars-d-learn
In order to call a function multiple time at parallel (rendering function, very well parallelizable), but in order to push the CPU to it's limits I have to get some form of parallelization. Currently I'm using parallel foreach, which isn't very nice, and since it uses GC allocation that

Re: Game and GC

2018-04-08 Thread solidstate1991 via Digitalmars-d-learn
On Monday, 9 April 2018 at 01:01:18 UTC, Chris Katko wrote: Why... associative arrays? Wouldn't that become expensive when you hit 1,000s, or 10,000's of objects, for something as tiny as a coordinate (two or three floats) lookup? Well, that's the other reason why I was looking for a different

Checking if a function pointer is set or null

2018-04-08 Thread solidstate1991 via Digitalmars-d-learn
Would the if(!(myFunctionPointer is null)){} work is I intended?

Re: Game and GC

2018-04-08 Thread solidstate1991 via Digitalmars-d-learn
On Saturday, 24 February 2018 at 07:12:21 UTC, Guillaume Piolat wrote: From my experience a combination of the following is necessary: - not having the audio thread registered - using pools aggressively for game entities Also you can save a lot of clockcycles if you put @nogc everywhere you

Re: Issues using the in-line assembler

2018-04-05 Thread solidstate1991 via Digitalmars-d-learn
Seems I found a better solution hidden in the docs: @nogc protected int[2] transformFunc(int[2] xy){ version(X86){ asm @nogc{ naked; mov EBX, this; movdXMM1, sX[EBX]; pslldq XMM1, 4; movss XMM1, sY[EBX];

Re: Issues using the in-line assembler

2018-04-05 Thread solidstate1991 via Digitalmars-d-learn
On Thursday, 5 April 2018 at 04:48:02 UTC, Basile B. wrote: The "this" seems to be in R11, so you have to apply the asm syntax for accessing the members using .offsetof.[R11], example: ``` class Foo { double a = 123456; extern(D) double foo() { asm {

Re: Issues using the in-line assembler

2018-04-04 Thread solidstate1991 via Digitalmars-d-learn
I forgot to tell, that xy0 ac, and bd are local to the class.

Issues using the in-line assembler

2018-04-04 Thread solidstate1991 via Digitalmars-d-learn
I have this code: asm @nogc{ movqXMM0, xy; paddd XMM0, sXY; // xy + sXY movqXMM3, xy0; psubd XMM0, XMM3; // xy + sXY - x0y0 movqXMM1, ac; movqXMM2, bd; pmuludq

Re: Alias on an array element

2017-10-12 Thread solidstate1991 via Digitalmars-d-learn
On Friday, 13 October 2017 at 01:09:56 UTC, solidstate1991 wrote: I'm making a struct for easy color handling Here's a code sample: ublic struct Color{ union{ uint raw; ///Raw representation in integer form, also forces the system to align in INT32. ubyte[4] colors; ///Normal

Alias on an array element

2017-10-12 Thread solidstate1991 via Digitalmars-d-learn
I'm making a struct for easy color handling Here's a code sample: ublic struct Color{ union{ uint raw; ///Raw representation in integer form, also forces the system to align in INT32. ubyte[4] colors; ///Normal representation, aliases are used for color naming.

How to use encode and decode of std.utf

2017-09-09 Thread solidstate1991 via Digitalmars-d-learn
There's not much deep documentation about the functions, and I'm interested if it can decode into UTF16 from UTF8.

Re: D is Multiplatform[DUVIDA]

2017-09-09 Thread solidstate1991 via Digitalmars-d-learn
On Friday, 8 September 2017 at 05:13:18 UTC, dark777 wrote: On Friday, 8 September 2017 at 03:56:25 UTC, rikki cattermole wrote: On 08/09/2017 3:08 AM, dark777 wrote: On Friday, 8 September 2017 at 00:09:08 UTC, solidstate1991 wrote: On Thursday, 7 September 2017 at 23:58:05 UTC, dark777

Re: D is Multiplatform[DUVIDA]

2017-09-07 Thread solidstate1991 via Digitalmars-d-learn
On Thursday, 7 September 2017 at 23:58:05 UTC, dark777 wrote: Good night, did you want to know this? Is the DE language cross-platform or cross-compile like C ++? GDC and LDC has multi-platform support, I'm currently working on an ARM backend for DMD.

Re: 24-bit int

2017-09-02 Thread solidstate1991 via Digitalmars-d-learn
On Friday, 1 September 2017 at 19:39:14 UTC, EntangledQuanta wrote: Is there a way to create a 24-bit int? One that for all practical purposes acts as such? This is for 24-bit stuff like audio. It would respect endianness, allow for arrays int24[] that work properly, etc. If you need to

Re: How can I serialize a struct into a file in the style of C?

2017-07-22 Thread solidstate1991 via Digitalmars-d-learn
On Saturday, 22 July 2017 at 02:22:53 UTC, Mike Parker wrote: I should add, though, that you're better off using either std.stdio.File or std.file. Use the former if you need to make multiple reads/writes to a file, the latter if you can pull it in or push it out all in one go. They take

How can I serialize a struct into a file in the style of C?

2017-07-21 Thread solidstate1991 via Digitalmars-d-learn
Due to it's convenience, I was thinking on reading and writing file headers by creating structs mirroring the layouts of actual headers I would need. I've seen many examples of this in C, however I' struggling using the same methods through the use of code.stdc.stdio, especially as I can't

Re: iOS Apps in D

2017-05-31 Thread solidstate1991 via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 12:49:38 UTC, Oleksii wrote: Hi everybody, Perhaps this topic has been raised many times before, but I'm going to go back to it anyways :-P Are there any good reference materials and/or tutorials on programming for iOS and Android in D? I wonder if anybody could

Re: How to setup DLL and EXE projects in one VS solution

2017-05-17 Thread solidstate1991 via Digitalmars-d-learn
On Wednesday, 17 May 2017 at 16:56:13 UTC, Igor wrote: At the moment I have: EXEProject: app.d - it does loadlibrary of dllproj and uses data structures defined in dllproj.d (it imports dllproj). On the file system this file is under /platform/win32/ and is defined as module win32.app;

Re: ordered Associative array

2017-04-13 Thread solidstate1991 via Digitalmars-d-learn
On Friday, 14 April 2017 at 00:29:34 UTC, Jethro wrote: Is there a way to retain the ordering of an associative array? When the elements are added then looped over using a foreach, the order is different. Use a separate array to store the keys, order them all time when you add a new one,

Re: Use of "T"

2017-04-12 Thread solidstate1991 via Digitalmars-d-learn
On Wednesday, 12 April 2017 at 16:05:23 UTC, XavierAP wrote: On Wednesday, 12 April 2017 at 14:46:20 UTC, solidstate1991 wrote: T is just the common name of a (type) parameter, mostly whenever the template is more generic that you can't think of a more informative (template) parameter

Re: Use of "T"

2017-04-12 Thread solidstate1991 via Digitalmars-d-learn
On Wednesday, 12 April 2017 at 13:54:11 UTC, qznc wrote: On Wednesday, 12 April 2017 at 13:17:42 UTC, solidstate1991 wrote: How can I make use of T? I've seen it being used many times for this application. What "T"? This letter is often used as a generic template parameter. Are you talking

Use of "T"

2017-04-12 Thread solidstate1991 via Digitalmars-d-learn
Some utilities of my game engine needs a two-way "dictionary", mainly for increasing the readability of configuration files, but I was thinking on letting the end-user to use it for certain things and I don't want to recreate the encode/decode/load from SDLang file functions every time I have

Re: Problems with setting up dub for publication

2017-03-04 Thread solidstate1991 via Digitalmars-d-learn
Replaced all the ~> with ==, now I'm getting error from dub wanting to use the alpha versions of the derelict libraries, which have minor compatibility issues with my project.

Problems with setting up dub for publication

2017-03-04 Thread solidstate1991 via Digitalmars-d-learn
My graphics engine contains two subpackages currently: -PixelPerfectEngine (the engine itself) -PixelPerfectEditor (the editor/converter, uses the engine itself to display screen data) However, after I wrote the dub.json and try to compile it as a test, I get this output: Building package

Reading image files

2016-11-25 Thread solidstate1991 via Digitalmars-d-learn
After I couldn't figure out how to convert Imageformats' own format to my own (consequential read from IFImage resulted in a glitchy image after rendering the result) and I have no idea how DerelictFI works at all, I'm currently out of options. At least I need PNG and TGA (the latter is

Multi-threading how-to

2016-08-31 Thread solidstate1991 via Digitalmars-d-learn
I decided to write a shared library for OSC in D despite the lack of popularity. I decided to add a functionality that if multiple programs use the same instance of the library on the same computer, the messages will be passed directly instead of via networking. Unfortunately we barely

Is this a bug or I made some mistake?

2016-08-29 Thread solidstate1991 via Digitalmars-d-learn
Since I have some screenshots: https://twitter.com/EvilReptoid/status/770303804550021121 I needed a bitarray, that had some more capability than the one in std.bitmanip for collision detection. I could test a whole line with it at once if my predictions are right. However I couldn't do the

Using external libraries the correct way

2016-07-17 Thread solidstate1991 via Digitalmars-d-learn
Up to this day, I have to use them by dragging the source into my project. When I tried to import imageformats, the compiler looks up for the file imageformats.d and fails to finish the program. I'm not using command line for compiling, I use Xamarin with mono-D instead.

Creating a JSON file

2015-02-03 Thread solidstate1991 via Digitalmars-d-learn
I wrote my graphics engine with CodeBlocks, and I only used dub when I complied the derelict SDL2 libs. https://github.com/ZILtoid1991/VDP-engine You can find the sources here.