Re: How to make a generic function to take a class or struct by reference?

2022-03-27 Thread vit via Digitalmars-d-learn
On Sunday, 27 March 2022 at 16:27:44 UTC, JN wrote: I would like to have only one definition of getX if possible, because they both are doing the same thing. I can't remove the ref one, because without a ref it will pass the struct as a temporary and compiler won't like that. ```d import

Re: Windows Msys terminal not flushing on newlines

2022-03-27 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 27 March 2022 at 18:09:30 UTC, Adam D Ruppe wrote: Normally the IOLBF thing does help there - that means line buffering - but my recommentation is to explicitly call `stdout.flush()` any time it is important in your code. Then you aren't depending on the relatively hidden config

Re: Windows Msys terminal not flushing on newlines

2022-03-27 Thread kdevel via Digitalmars-d-learn
Don't know if this is OT here. On Sunday, 27 March 2022 at 18:09:30 UTC, Adam D Ruppe wrote: If the C library thinks it is talking to a pipe, it will switch to block buffering instead of line buffering. It must just think msys is a pipe (since it probably is under the hood). while compiling

Re: How to make a generic function to take a class or struct by reference?

2022-03-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/27/22 12:27 PM, JN wrote: int* getX(T)(T t) {     return } Remove this one. It's a bad idea. It probably won't compile, but if it does, you will be using corrupted memory. -Steve

Re: Windows Msys terminal not flushing on newlines

2022-03-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 27 March 2022 at 17:46:54 UTC, Anonymouse wrote: I installed Git for Windows which comes with the Msys terminal, and I noticed writeln lines aren't being flushed on linebreaks If the C library thinks it is talking to a pipe, it will switch to block buffering instead of line

Windows Msys terminal not flushing on newlines

2022-03-27 Thread Anonymouse via Digitalmars-d-learn
I installed Git for Windows which comes with the Msys terminal, and I noticed writeln lines aren't being flushed on linebreaks. I had this a long time ago and thought I fixed it with the following, but I guess I never confirmed that it actually worked. I'm not sure where I copied it from, a

Re: How to make a generic function to take a class or struct by reference?

2022-03-27 Thread drug via Digitalmars-d-learn
Auto ref? ```D int* getX(T)(auto ref T t) { ... ```

How to make a generic function to take a class or struct by reference?

2022-03-27 Thread JN via Digitalmars-d-learn
I would like to have only one definition of getX if possible, because they both are doing the same thing. I can't remove the ref one, because without a ref it will pass the struct as a temporary and compiler won't like that. ```d import std.stdio; struct Foo { int x; void doStuff()

Re: Help needed to learn typeof(return)

2022-03-27 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 27 March 2022 at 01:11:02 UTC, Steven Schveighoffer wrote: Not sure what the question here is, Thanks for the reply. Actually, my problem was this, I forgot the presence of `LargerOf!(A, B)` template function in that chapter. When I see it in a function, I thought where is the

Re: Example of Windows SSL with Secure Channel?

2022-03-27 Thread janrinok via Digitalmars-d-learn
On Monday, 21 March 2022 at 17:30:31 UTC, Marcone wrote: I hope one day the creators of the D programming language will implement std.socket.ssl ​​in the Phobos library. I have to agree. For those just getting to grips with D there are some things in the library that just make using them much