Passing D reimplementation of C++ template as argument to a C++ function

2022-09-24 Thread Gregor Mückl via Digitalmars-d-learn
Hi! I have a D template struct that reimplements a C++ class template with identical memory layout for a set of types that matter to me. Now, I want to use some C++ functions and classes that use these template instances, from D. For that, I want to purposefully alias the D and C++ types. How

Re: Passing D reimplementation of C++ template as argument to a C++ function

2022-10-09 Thread Gregor Mückl via Digitalmars-d-learn
On Sunday, 25 September 2022 at 23:23:51 UTC, Nicholas Wilson wrote: On Saturday, 24 September 2022 at 07:04:34 UTC, Gregor Mückl wrote: extern(C++) extern(C++, class) struct Foo(T) { T a, b; } alias FooFloat = Foo!float; extern(C++) void bar(FooFloat f); ``` This works when you mirror al

Re: How to move from Unique(someClass) to Unique(someInterface)?

2022-11-28 Thread Gregor Mückl via Digitalmars-d-learn
On Monday, 28 November 2022 at 02:40:28 UTC, Tejas wrote: On Sunday, 27 November 2022 at 17:06:31 UTC, vushu wrote: On Saturday, 16 May 2020 at 17:45:56 UTC, Konstantin wrote: [...] I'm actually also very curious about this issue, since I come from c++ where this is possible, and it is a ver

Re: Windows specific: MS C++ versus D thread local variables

2022-11-28 Thread Gregor Mückl via Digitalmars-d-learn
On Monday, 28 November 2022 at 18:51:37 UTC, NonNull wrote: I tested this with D threads and it works for my test program. I might guess that this is so in general, because such a library has to successfully work with arbitrary MS VC++ and that "interop" is defined by MS to work. I worked on

Re: Is there such concept of a list in D?

2022-12-12 Thread Gregor Mückl via Digitalmars-d-learn
On Sunday, 11 December 2022 at 17:45:20 UTC, ryuukk_ wrote: There is: https://dlang.org/phobos/std_container_dlist.html Why is it called ``DList`` and not just ``List``, i have no clue The D is to indicate that it is a doubly-linked list. It maintains a forward and backward pointer chain to s

Bind C++ template specialized with void parameter

2024-02-28 Thread Gregor Mückl via Digitalmars-d-learn
I have roughly the following code in C++ (vastly simplified from reality): ```cpp template class Wrapper { private: T t; bool valid; public: bool isValid() { return valid; } }; template<> class Wrapper\ { private: bool valid; public: bool isValid() { return valid; } }; ``` I can b

Re: Bind C++ template specialized with void parameter

2024-02-29 Thread Gregor Mückl via Digitalmars-d-learn
On Thursday, 29 February 2024 at 10:30:59 UTC, DUser wrote: On Wednesday, 28 February 2024 at 22:48:33 UTC, Gregor Mückl wrote: ... But how can I bind Wrapper\ in D? Specifically, how do I even express that template specialization in D syntax? Did you mean any of these? 1. Parameter speciali

Re: Need help with Windows linkage ( DMD using ImportC)

2024-03-07 Thread Gregor Mückl via Digitalmars-d-learn
On Tuesday, 5 March 2024 at 00:20:36 UTC, Carl Sturtivant wrote: On Monday, 4 March 2024 at 21:21:20 UTC, Carl Sturtivant wrote: ``` blah.obj: error LNK2019: unresolved external symbol _mul128 referenced in function MultiplyExtract128 blah.obj: error LNK2019: unresolved external symbol __shift

Re: Deactivate windows MessageBox dialog on exception

2019-08-28 Thread Gregor Mückl via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 12:19:54 UTC, Andre Pany wrote: Hi, I call another process using function pipeShell and Redirect.all. In case the child process(also D application) throws an exception (str to int conversion exception), the child process shows a message box on windows. I fo

Re: Deactivate windows MessageBox dialog on exception

2019-08-28 Thread Gregor Mückl via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 13:15:14 UTC, a11e99z wrote: On Wednesday, 28 August 2019 at 12:19:54 UTC, Andre Pany wrote: Hi, I call another process using function pipeShell and Redirect.all. import std; void main() { auto p = pipeShell("a.exe", Redirect.all); p.stdin.writeln("

Re: Indexed graphics for retro engine?

2019-09-20 Thread Gregor Mückl via Digitalmars-d-learn
On Thursday, 19 September 2019 at 20:47:45 UTC, Shadowblitz16 wrote: can I do this in D and draw them to a 32bpp bitmap pixel by pixel? I would prefer do do this on the gpu but I don't know how. Conceptually, applying the palette to the index buffer is easy on the GPU. There are two ways to g

Re: D create many thread

2020-02-05 Thread Gregor Mückl via Digitalmars-d-learn
On Wednesday, 5 February 2020 at 15:54:23 UTC, Steven Schveighoffer wrote: I think we should be more selective about when we make parallel threads to scan (maybe above a certain size of used memory?). -Steve That threshold would have to adapt to each system. How about delaying thread startup

Re: Dub - vibe.d - hunt framework ... problems

2020-02-06 Thread Gregor Mückl via Digitalmars-d-learn
On Saturday, 1 February 2020 at 10:35:52 UTC, seany wrote: Hi I want to start a small server, that will be accessible form outside. Not a huge deal right? Not quite. My machine: 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux DMD : DMD64 D Compile

How to get to body of HTTP 500 error with std.net.curl.get()?

2020-02-13 Thread Gregor Mückl via Digitalmars-d-learn
Hi! I am trying to write a client for pretty... well... creatively designed web API. The server gives HTTP status 500 replies if the requests are malformed, but the actual error message is hidden in the body of the reply (an XML document!). std.net.curl.get() throws an exception in this case.

Re: How to get to body of HTTP 500 error with std.net.curl.get()?

2020-02-15 Thread Gregor Mückl via Digitalmars-d-learn
On Friday, 14 February 2020 at 13:23:01 UTC, Andre Pany wrote: On Friday, 14 February 2020 at 00:24:27 UTC, Gregor Mückl wrote: Hi! I am trying to write a client for pretty... well... creatively designed web API. The server gives HTTP status 500 replies if the requests are malformed, but the

Safely wrapping an uncopyable struct to implement an interface

2020-03-04 Thread Gregor Mückl via Digitalmars-d-learn
Hi! I've just created a situation in my code that is summarized by the following example. I don't know how to solve it with @safe code. A third party library provides a struct that is not copyable: // provided by third party struct Foo { @disable this() @safe; @disable this(ref retur

Re: Best way to learn 2d games with D?

2020-03-21 Thread Gregor Mückl via Digitalmars-d-learn
On Sunday, 15 March 2020 at 17:58:58 UTC, Steven Schveighoffer wrote: I want to try and learn how to write 2d games. I'd prefer to do it with D. I've found a ton of tutorials on learning 2d gaming with other languages. Is there a place to look that uses D for learning? Should I just start wit

Re: To get memory from another process.

2020-04-09 Thread Gregor Mückl via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 21:04:42 UTC, Quantium wrote: I'm trying to do this because I have very special programm that makes some calculations and on every calculation there is a hash in RAM. I need to get a one of hash values from a .bin file, and replace them. I mean hash in RAM of the p

std.algorithm.sort with copy constructors

2020-04-13 Thread Gregor Mückl via Digitalmars-d-learn
Hi! Consider the following code: --- import std; struct S { pure this(ref return scope const S rhs) nothrow @nogc { this.x = x; } int x; } void main() { S[] array = new S[10]; array.sort!("a.x < b.x", SwapStrategy.stable); } --- In this program, sort compiles on

Re: std.algorithm.sort with copy constructors

2020-04-14 Thread Gregor Mückl via Digitalmars-d-learn
On Monday, 13 April 2020 at 15:38:33 UTC, Steven Schveighoffer wrote: On 4/13/20 10:24 AM, Steven Schveighoffer wrote: This is a bug in phobos. https://issues.dlang.org/show_bug.cgi?id=20732 https://github.com/dlang/phobos/pull/7442 -Steve Sorry for sending you down that particular rabbit

Wrapping C++ class with virtual destructor

2021-02-17 Thread Gregor Mückl via Digitalmars-d-learn
Hi! How do I wrap an existing C++ class with a virtual destructor in D? Take, for example, this C++ class: class Base { public: virtual ~Base(); virtual void foo() = 0; } What does the equivalent extern(C++) declaration in D look like? I don't care about calling the destructor. My o

Class member initialization with new points to a single instance?

2021-06-09 Thread Gregor Mückl via Digitalmars-d-learn
Consider the following code: ```d class Foo { } class Bar { Foo foo = new Foo(); } void main() { Bar b1 = new Bar(); Bar b2 = new Bar(); assert(b1.foo != b2.foo); } ``` The assert fails. This is completely surprising to me. Is this actually expected?

Re: Class member initialization with new points to a single instance?

2021-06-09 Thread Gregor Mückl via Digitalmars-d-learn
On Wednesday, 9 June 2021 at 18:04:54 UTC, evilrat wrote: On Wednesday, 9 June 2021 at 17:56:24 UTC, Gregor Mückl wrote: Consider the following code: ```d class Foo { } class Bar { Foo foo = new Foo(); } void main() { Bar b1 = new Bar(); Bar b2 = new Bar(); assert(b1