On Wednesday, 8 July 2020 at 02:06:01 UTC, Steven Schveighoffer
wrote:
OK, so I have a situation where I'm foreaching over a
compile-time list of types. Inside the loop, I'm using a second
loop over a set of input.
Inside that loop, I'm using a switch on the input, and inside
the switch, I'm
OK, so I have a situation where I'm foreaching over a compile-time list
of types. Inside the loop, I'm using a second loop over a set of input.
Inside that loop, I'm using a switch on the input, and inside the
switch, I'm foreaching over the type's members, to construct a switch
that can
How can I make DMD stop on the first fatal error like
-Wfatal-errors on C++?
On 7/7/20 12:53 PM, IGotD- wrote:
ubyte[3] ar = [ 1, 2, 3 ];
ubyte[] arSlice = ar;
overloadedFunction(arSlice);
The first function will be used. Shouldn't the template argument (T :
T[]) make the compiler pick the second one?
There is also template constraints which may be useful:
import
On 7/7/20 4:21 PM, IGotD- wrote:
On Tuesday, 7 July 2020 at 20:14:19 UTC, IGotD- wrote:
Thank you, that worked and now it picked the correct overloaded
function. I don't understand why and it is a bit counter intuitive.
Why two template arguments as I'm not even us using U?
If you look at
On 7/6/20 5:20 PM, solidstate1991 wrote:> 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
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)`,
On Tuesday, 7 July 2020 at 20:14:19 UTC, IGotD- wrote:
Thank you, that worked and now it picked the correct overloaded
function. I don't understand why and it is a bit counter
intuitive. Why two template arguments as I'm not even us using
U?
If you look at the article
On Tuesday, 7 July 2020 at 20:05:37 UTC, Steven Schveighoffer
wrote:
On 7/7/20 4:04 PM, Steven Schveighoffer wrote:
Have you tried (T: U[], U)(ref T[] s) ?
Ugh... (T: U[], U)(ref T s)
-Steve
Thank you, that worked and now it picked the correct overloaded
function. I don't understand why
On 7/7/20 4:04 PM, Steven Schveighoffer wrote:
Have you tried (T: U[], U)(ref T[] s) ?
Ugh... (T: U[], U)(ref T s)
-Steve
On Tuesday, 7 July 2020 at 19:53:30 UTC, IGotD- wrote:
...
I also forgot to mention that the overloadedFunction is used in a
variadic template function.
void processAll(T...)(ref T t)
{
foreach(ref v; t)
{
overloadedFunction(v);
}
}
On 7/7/20 3:53 PM, IGotD- wrote:
I have two template functions
void overloadedFunction(T)(ref T val)
{
}
void overloadedFunction(T : T[])(ref T[] s)
{
}
Obviously the second should be used when the parameter is a slice of any
type, and the first should be used in other cases.
I have two template functions
void overloadedFunction(T)(ref T val)
{
...
}
void overloadedFunction(T : T[])(ref T[] s)
{
...
}
Obviously the second should be used when the parameter is a slice
of any type, and the first should be used in other cases. However
this doesn't
On Tuesday, 7 July 2020 at 06:34:15 UTC, adnan338 wrote:
I have a separate version for flatpak builds in my app. Let's
say I have a large project that builds with dub that goes like
this:
import std.stdio;
void main()
{
version (flatpak) {
writeln(`Flatpak build`);
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)`,
On Saturday, 4 July 2020 at 14:44:06 UTC, Kagamin wrote:
try
https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-setunhandledexceptionfilter
Thank You, this was the winner for me.
Not just I can catch the OS Exceptions, I can check and alter the
CPU state and
On Tuesday, 7 July 2020 at 00:20:40 UTC, solidstate1991 wrote:
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 {
On 7/7/20 8:26 AM, Steven Schveighoffer wrote:
On 7/6/20 5:09 PM, kinke wrote:
On Monday, 6 July 2020 at 20:25:11 UTC, Kayomn wrote:
Though, admittedly I'm kind of used to seeing this error message
since it appears any time you try and do something that relies on
type info in betterC,
On Monday, 6 July 2020 at 12:04:11 UTC, Jacob Carlborg wrote:
void main() @nogc
{
auto a = tuple(Pair("foo", 1), Pair("bar", 2));
}
--
/Jacob Carlborg
Thanks.
What about construction and assignment from a static array of
`Pair`'s? Wouldn't that be easier on the compiler?
On 7/6/20 5:09 PM, kinke wrote:
On Monday, 6 July 2020 at 20:25:11 UTC, Kayomn wrote:
Though, admittedly I'm kind of used to seeing this error message since
it appears any time you try and do something that relies on type info
in betterC, intentionally or not. A notable example is forgetting
On 7/7/20 3:08 AM, mw wrote:
On Tuesday, 19 May 2015 at 12:21:48 UTC, Steven Schveighoffer wrote:
On 5/18/15 7:55 PM, Freddy wrote:
How do you allocate an associative array on the heap?
void main(){
alias A=int[string];
auto b=new A;
}
$ rdmd test
test.d(4): Error: new can
On 7/6/20 5:04 PM, claptrap wrote:
Ok yeah it starts up a server and opens a webpage, great, but where are
the docs? Cant find any info on command line switches for dub or ddox on
how to get it to just dump the docs in a folder.
dub --build=ddox
makes a server and runs it so you can serve
On Tuesday, 7 July 2020 at 00:35:38 UTC, Marcone wrote:
Hi, I study Dlang for one year, and I can't understand alias
this. I need an Easy example to understand Alias This.
I used it for widget inheritance in my experimental code here,
On Tuesday, 7 July 2020 at 00:44:32 UTC, Marcone wrote:
On Tuesday, 7 July 2020 at 00:42:40 UTC, Ali Çehreli wrote:
On 7/6/20 5:35 PM, Marcone wrote:
Hi, I study Dlang for one year, and I can't understand alias
this. I need an Easy example to understand Alias This.
Is the following example
On Tuesday, 19 May 2015 at 12:21:48 UTC, Steven Schveighoffer
wrote:
On 5/18/15 7:55 PM, Freddy wrote:
How do you allocate an associative array on the heap?
void main(){
alias A=int[string];
auto b=new A;
}
$ rdmd test
test.d(4): Error: new can only create structs, dynamic
I have a separate version for flatpak builds in my app. Let's say
I have a large project that builds with dub that goes like this:
import std.stdio;
void main()
{
version (flatpak) {
writeln(`Flatpak build`);
} else {
writeln("Edit source/app.d
26 matches
Mail list logo