On Wednesday, 5 August 2020 at 16:13:19 UTC, Andrej Mitrovic
wrote:
```
C:\dev> rdmd -m64 --eval="import core.stdc.time;
writeln(time_t.sizeof);"
4
```
According to MSDN this should not be the case:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=vs-20
On Thursday, 6 August 2020 at 01:13:28 UTC, Victor L Porton wrote:
When to use core.thread and when std.concurrency for
multithreading in applications? Is one of them a preferred way?
Druntime's core.thread sets the foundation for D's
multi-threading (or at least the non-betterC foundation). O
On Thursday, 6 August 2020 at 21:50:06 UTC, Per Nordlöw wrote:
I just discovered that the is-operator can be used as in
template ElementType(R)
{
static if (is(typeof(R.init.front.init) T))
alias ElementType = T;
else
alias ElementType = void;
}
. Very powerful. Is this
On Thursday, 6 August 2020 at 17:18:12 UTC, rikki cattermole
wrote:
On 07/08/2020 5:12 AM, wjoe wrote:
There's core.memory.GC.reserve which requests memory from the
OS. Basically pre-allocating memory for the GC heap.
Is the GC heap shared among all threads ?
That is up to the GC implementat
I just discovered that the is-operator can be used as in
template ElementType(R)
{
static if (is(typeof(R.init.front.init) T))
alias ElementType = T;
else
alias ElementType = void;
}
. Very powerful. Is this documented?
On Thursday, 6 August 2020 at 21:50:06 UTC, Per Nordlöw wrote:
I just discovered that the is-operator can be used as in
...
Doh, title should of course be
I just discovered an alternative use of `is`-expressions.
Thank you for your comments :)
I tried again this morning, and the problem persisted... I have
just reinstalled my D environment. It must have been badly
installed, because now everything is working normally.
Looking at the installation files, I saw that there was a
dependency to libcurl. Ma
On 8/6/20 4:44 AM, Per Nordlöw wrote:
On Thursday, 6 August 2020 at 01:13:28 UTC, Ali Çehreli wrote:
Boring in D. :p
template maxSizeOf(T...) {
enum maxSizeOf = compute();
auto compute() {
size_t result;
static foreach (t; T) {
if (t.sizeof > result) {
result = t.size
On Thursday, 6 August 2020 at 18:09:50 UTC, ag0aep6g wrote:
[snip]
`is(...)` only works on types. You're looking for
`__traits(isSame, T, Foo)`.
For `is(T!U == Foo!U, U)` to work, the compiler would have to
guess U. If the first guess doesn't work, it would have to
guess again, and again, a
On Thursday, 6 August 2020 at 16:01:35 UTC, jmh530 wrote:
The code below compiles, but I want to put an additional
constraint on the `test` function is only called with a Foo
struct.
I tried things like is(T == Foo) and is(T : Foo), but those
don't work. However, something like is(T!int : Foo
On Thursday, 6 August 2020 at 16:01:35 UTC, jmh530 wrote:
[snip]
It seems as if the T is properly Foo(T) and can only be
instantiated with actual types. Something like below works and
might work for me.
template test(alias T)
if (__traits(isTemplate, T))
{
void test(U)(U x)
On 07/08/2020 5:12 AM, wjoe wrote:
There's core.memory.GC.reserve which requests memory from the OS.
Basically pre-allocating memory for the GC heap.
Is the GC heap shared among all threads ?
That is up to the GC implementation.
And is it correct that even if I call GC.disable, the GC may st
There's core.memory.GC.reserve which requests memory from the OS.
Basically pre-allocating memory for the GC heap.
Is the GC heap shared among all threads ?
E.g what happens if I GC.reserve(4.MiB) ? Is it 4 MiB in total or
per thread ?
And is it correct that even if I call GC.disable, the GC
The code below compiles, but I want to put an additional
constraint on the `test` function is only called with a Foo
struct.
I tried things like is(T == Foo) and is(T : Foo), but those don't
work. However, something like is(T!int : Foo!int) works, but
is(T!U == Foo!U, U) doesn't. Any idea why
On 8/6/20 9:23 AM, Adam D. Ruppe wrote:
On Thursday, 6 August 2020 at 13:18:40 UTC, Per Nordlöw wrote:
mixin(T.stringof ~ " _store" ~ T.mangleof ~
Never ever use mixin(T.stringof). Always just use mixin("T") instead.
mixin("T _store", T.mangleof /* or just idx is gonna be bett
On Thu, Aug 06, 2020 at 01:07:14PM +, Per Nordlöw via Digitalmars-d-learn
wrote:
[...]
> However, your solution
>
> template maxSize(T...)
> {
> align(1) union Impl { T t; }
> enum maxSize = Impl.sizeof;
> }
>
> fails as
>
> variable `std.variant.maxSize!(void, string).Impl.__t_fi
On Thursday, 6 August 2020 at 13:18:40 UTC, Per Nordlöw wrote:
Can somebody find a better alternative?
Let's continue discussion at
https://github.com/dlang/phobos/pull/7582
On Thursday, 6 August 2020 at 13:18:40 UTC, Per Nordlöw wrote:
mixin(T.stringof ~ " _store" ~ T.mangleof ~
Never ever use mixin(T.stringof). Always just use mixin("T")
instead.
mixin("T _store", T.mangleof /* or just idx is gonna be better
*/,";");
Though I doubt this is g
On Thursday, 6 August 2020 at 13:07:14 UTC, Per Nordlöw wrote:
Do you have any simple solution to this, H. S. Teoh?
I also tried
template maxSize(Ts...)
{
align(1) union Impl
{
// See_Also:
https://forum.dlang.org/thread/wbpnncxepehgcswhu...@forum.dlang.org?page=1
sta
On Thursday, 6 August 2020 at 12:51:22 UTC, H. S. Teoh wrote:
Of course. In fact, it's trivial:
--
template maxSizeOf(T...)
{
align(1) union Impl {
T t;
}
enum maxSizeOf = Impl.sizeof;
}
I originally copied my original version of `maxSizeOf` from
`s
On Thursday, 6 August 2020 at 12:51:22 UTC, H. S. Teoh wrote:
Of course. In fact, it's trivial:
--
template maxSizeOf(T...)
{
align(1) union Impl {
T t;
}
enum maxSizeOf = Impl.sizeof;
}
Clever. Thanks
On Thursday, 6 August 2020 at 00:58:39 UTC, Per Nordlöw wrote:
Is it possible to implement
template maxSizeOf(T...)
{
static if (T.length == 1)
enum size_t maxSizeOf = T[0].sizeof;
else
{
enum size_t firstSize = T[0].sizeof;
enum size_t maxSizeRest = maxSizeOf
On Thursday, 6 August 2020 at 07:24:23 UTC, WebFreak001 wrote:
On Thursday, 6 August 2020 at 07:19:37 UTC, WebFreak001 wrote:
[...]
In line 11 in my example code this makes a better, safer if
than `if (s.length)`:
if (s.length && s[$ - 1] == '\n') s = s[0 .. $ - 1];
Note that I only need to
On Thursday, 6 August 2020 at 01:13:28 UTC, Ali Çehreli wrote:
Boring in D. :p
template maxSizeOf(T...) {
enum maxSizeOf = compute();
auto compute() {
size_t result;
static foreach (t; T) {
if (t.sizeof > result) {
result = t.sizeof;
}
}
return result;
On Wednesday, 5 August 2020 at 17:32:49 UTC, vanaur wrote:
My concern is thus the following: I can't add packages to my
project, Dub warns me that they are not available.
For the example, I try to add this dependency
(https://code.dlang.org/packages/pegged) with the following
command: dub
On Monday, 3 August 2020 at 15:33:54 UTC, Dominikus Dittes
Scherkl wrote:
[...]
For really long expressions you could also split it on multiple
lines:
c = (b_expression == 0)
? (d_longer_expression)
: (a_expression/b_expression);
+1 looks clean!
On Thursday, 6 August 2020 at 07:19:37 UTC, WebFreak001 wrote:
[...]
In line 11 in my example code this makes a better, safer if than
`if (s.length)`:
if (s.length && s[$ - 1] == '\n') s = s[0 .. $ - 1];
Note that I only need to do this because of the readln API, it
would be much safer and
On Wednesday, 5 August 2020 at 17:39:36 UTC, Mike Surette wrote:
In my efforts to learn D I am writing some code to read files
in different UTF encodings with the aim of having them end up
as UTF-8 internally. As a start I have the following code:
import std.stdio;
import std.file;
void main(
28 matches
Mail list logo