Re: Non-recursive maxSizeOf

2020-08-05 Thread lithium iodate via Digitalmars-d-learn
On Thursday, 6 August 2020 at 01:13:41 UTC, Adam D. Ruppe wrote: size_t maxSizeOf(T...)() { size_t max = 0; foreach(t; T) if(t.sizeof > max) max = t.sizeof; return max; } pragma(msg, maxSizeOf!(int, char, long)); more love for

Re: Array fill performance differences between for, foreach, slice

2020-04-01 Thread lithium iodate via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 06:48:09 UTC, Jacob Carlborg wrote: I you care about performance you should really compile using LDC (with `-O5 -release -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto`), which usually produces much better code: Slice: Mean time(usecs): 50.58, Standard

Re: "register int n" alternative

2020-02-16 Thread lithium iodate via Digitalmars-d-learn
On Sunday, 16 February 2020 at 15:15:44 UTC, Stefan Koch wrote: The register keyword as been deprecated for ages in C. Since the compiler cannot actually guarantee that the variable will be a register. As a result D does not have the register keyword. That only applies for C++, where it

Re: bindbc-opengl: Now drawing triangle

2020-01-25 Thread lithium iodate via Digitalmars-d-learn
On Saturday, 25 January 2020 at 19:52:25 UTC, Luhrel wrote: Hello, I made a simple OpenGL file using bindbc-opengl and glfw (https://pastebin.com/ehmcHwxj) based on https://github.com/SonarSystems/Modern-OpenGL-Tutorials/blob/master/%5BGETTING%20STARTED%5D/%5B1%5D%20Triangle/main.cpp The

Re: Fetching an element using find

2020-01-13 Thread lithium iodate via Digitalmars-d-learn
On Monday, 13 January 2020 at 17:58:57 UTC, Steven Schveighoffer wrote: On 1/13/20 12:47 PM, H. S. Teoh wrote: Why not write your own convenience wrapper? auto firstElement(R)(R r) if (isInputRange!R) { if (r.empty) throw new Exception(...);

Re: Speed of Random Numbers

2019-08-03 Thread lithium iodate via Digitalmars-d-learn
On Saturday, 3 August 2019 at 16:35:34 UTC, Giovanni Di Maria wrote: Do you know other faster functions or methods to generate random numbers? For me the "goodness of random" is NOT important. Thank you very much GIovanni Di Maria First off you could try to use a faster RNG engine than the

Re: There is a computer languages benchmark compare site, but no Dlang benchmark. I think they should support D.

2019-06-21 Thread lithium iodate via Digitalmars-d-learn
On Saturday, 22 June 2019 at 01:27:31 UTC, lili wrote: A nick site, has a lot of languages, unfortunately no dlang in there. https://benchmarksgame-team.pages.debian.net/benchmarksgame/ This page frequently pops up in this forum, please refer to existing posts:

Re: Range violation error when reading from a file

2019-06-16 Thread lithium iodate via Digitalmars-d-learn
On Sunday, 16 June 2019 at 23:44:49 UTC, Samir wrote: On Sunday, 16 June 2019 at 23:03:04 UTC, aliak wrote: stripping the last line could result in an empty line if it just has strippable characters? The last line of the file is just text but without a newline (\n) character or any other

Re: Compiler/Phobos/Types problem — panic level due to timing.

2019-05-05 Thread lithium iodate via Digitalmars-d-learn
On Sunday, 5 May 2019 at 18:53:08 UTC, Russel Winder wrote: Hi, I had merrily asumed I could implement nth Fibonacci number with: takeOne(drop(recurrence!((a, n) => a[n-1] + a[n-2])(zero, one), n)).front where zero and one are of type BigInt, and n is of type size_t. However both dmd

Re: == comparison of string literals, and their usage

2019-04-06 Thread lithium iodate via Digitalmars-d-learn
On Saturday, 6 April 2019 at 15:35:22 UTC, diniz wrote: So, I still could store and use and compare string pointers myself [1], and get valid results, meaning: pointer equality implies (literal) string equality. Or am I wrong? The point is, the parser, operating on an array of prescanned

Re: template with enum parameter doesn't compile

2019-04-05 Thread lithium iodate via Digitalmars-d-learn
On Friday, 5 April 2019 at 14:47:42 UTC, Sjoerd Nijboer wrote: So the following code doesn't compile for some reason, and I can't figure out why. The error: Error: template instance `MyClass!(MyEnum)` does not match template declaration `MyClass(MyEnum myEnum)` pops up, no matter what I do.

Re: question about bitfields to decode websocket header

2018-11-07 Thread lithium iodate via Digitalmars-d-learn
On Wednesday, 7 November 2018 at 13:05:49 UTC, test wrote: I am confused about the bitfields order. mixin(bitfields!( bool, "fin",1, bool, "rsv1", 1, bool, "rsv2", 1, bool, "rsv3", 1, Opcode, "opcode", 4,

Re: Why use while if only iterating once ?

2018-11-03 Thread lithium iodate via Digitalmars-d-learn
On Saturday, 3 November 2018 at 21:03:16 UTC, Venkat wrote: The last break statement prevents the loop from returned for a second iteration. Then why use a while ? The continue statement may abort the current iteration and start the next, causing the final break to not necessarily be executed

Re: Struct template cannot deduce function from argument types

2018-06-27 Thread lithium iodate via Digitalmars-d-learn
On Wednesday, 27 June 2018 at 16:19:56 UTC, Luka Aleksic wrote: […] I am getting the following error: scratch.d(14): Error: struct scratch.pair cannot deduce function from argument types !()(char, int), candidates are: scratch.d(2):scratch.pair(T, U) Failed: ["/usr/bin/dmd", "-v",

Re: For fun: Expressive C++ 17 Coding Challenge in D

2017-10-04 Thread lithium iodate via Digitalmars-d-learn
On Wednesday, 4 October 2017 at 15:30:08 UTC, Ali Çehreli wrote: the hidden \r characters at the ends Those got me too! Here's my less than optimal solution: int main(string[] args) { import std.stdio; import std.algorithm.iteration : map, splitter, joiner, each; import

Re: Array Printing

2017-09-12 Thread lithium iodate via Digitalmars-d-learn
On Tuesday, 12 September 2017 at 06:29:53 UTC, Vino.B wrote: Hi All, Request your help in printing the below array output as per the below required output As a fan of stuffing as much as possible into one line: void main() { import std.stdio; import std.range; import

Re: string to character code hex string

2017-09-02 Thread lithium iodate via Digitalmars-d-learn
On Saturday, 2 September 2017 at 17:41:34 UTC, Ali Çehreli wrote: You're right but I think there is no intention of interpreting the result as UTF-8. "f62026" is just to be used as "f62026", which can be converted byte-by-byte back to "ö…". That's how understand the requirement anyway. Ali

Re: string to character code hex string

2017-09-02 Thread lithium iodate via Digitalmars-d-learn
On Saturday, 2 September 2017 at 16:52:17 UTC, Ali Çehreli wrote: On 09/02/2017 09:23 AM, bitwise wrote: On Saturday, 2 September 2017 at 15:53:25 UTC, bitwise wrote: [...] This seems to work well enough. string toAsciiHex(string str) { import std.array : appender; auto ret =